Documentation ¶
Index ¶
- Variables
- func InitTables(db *gorm.DB) error
- type GormUserDAO
- func (gud *GormUserDAO) FindByEmail(ctx context.Context, email string) (User, error)
- func (gud *GormUserDAO) FindById(ctx context.Context, id int64) (User, error)
- func (gud *GormUserDAO) FindByPhone(ctx context.Context, phone string) (User, error)
- func (gud *GormUserDAO) Insert(ctx context.Context, u User) error
- type User
- type UserDAO
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDataNotFound = gorm.ErrRecordNotFound ErrUserDuplicate = errors.New("user email duplicate") )
Functions ¶
func InitTables ¶
Types ¶
type GormUserDAO ¶
type GormUserDAO struct {
// contains filtered or unexported fields
}
func (*GormUserDAO) FindByEmail ¶
func (*GormUserDAO) FindByPhone ¶
type User ¶
type User struct { Id int64 `gorm:"primaryKey;autoIncrement"` Email sql.NullString `gorm:"unique"` // 由于密码不需要设置成 unique(唯一索引), 因此他为""(空字符串)也没关系 Password string Nickname string `gorm:"type=varchar(128)"` Birthday int64 // YYYY-MM-DD AboutMe string `gorm:"type=varchar(4096)"` // 代表这是一个可以为 NULL 的列 // 唯一索引允许有多个 NULL, 但是不允许多个 "" Phone sql.NullString `gorm:"unique"` CreatedAt int64 // 统一 UTC +0, 涉及到时间的时候, 再处理时区(转换) UpdatedAt int64 }
Click to show internal directories.
Click to hide internal directories.