模型实体
package model
import (
"gorm.io/gorm"
"time"
)
type BaseModel struct {
ID int32 `gorm:"primaryKey"`
Createtime string `gorm:"type:timestamp"`
Deletetime gorm.DeletedAt // 用于软删除字段的
Isdeleted bool
}
type User struct {
BaseModel
Username string `gorm:"index:idx_mobile;unique;type:char(11);not null"` // 手机号
Password string `gorm:"type:varchar(256);not null"`
Nickname string `gorm:"type:varchar(32);"`
Email string `gorm:"type:varchar(64);"`
Birthday *time.Time `gorm:"type:datetime"`
Gender int32 `gorm:"type:tinyint(1) comment '0女,1男';default:1"`
Role int32 `gorm:"type:tinyint(1) comment '1普通用户,2管理员';default:1"`
}
原创大约 5 分钟