diff --git a/internal/model/user.go b/internal/model/user.go new file mode 100644 index 0000000..dac8c13 --- /dev/null +++ b/internal/model/user.go @@ -0,0 +1,21 @@ +package model + +import ( + "time" + + "gorm.io/gorm" +) + +// User 用户模型(管理端与用户端共用一套账号体系) +type User struct { + ID uint `gorm:"primaryKey" json:"id"` + Username string `gorm:"size:50;uniqueIndex;not null" json:"username"` + Password string `gorm:"size:255;not null" json:"-"` // bcrypt 哈希,不返回前端 + Phone string `gorm:"size:20;index" json:"phone"` // 手机号 + Role string `gorm:"size:20;default:user;not null" json:"role"` // admin | user + Avatar string `gorm:"size:255" json:"avatar"` // 头像 URL + Status int `gorm:"default:1;not null" json:"status"` // 1=正常 0=禁用 + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` +}