package model import ( "time" "gorm.io/gorm" ) // 用户角色 const ( RoleAdmin = "admin" // 平台管理员 RoleMerchant = "merchant" // 商户账号 ) // User 系统用户 type User struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // Username uniqueness is enforced by a partial database index for active // accounts, allowing a username to be reused after its old account is soft deleted. Username string `gorm:"size:64;not null" json:"username"` PasswordHash string `gorm:"size:255;not null" json:"-"` Nickname string `gorm:"size:64" json:"nickname"` Role string `gorm:"size:32;not null;default:merchant" json:"role"` Status int `gorm:"default:1" json:"status"` // 1启用 0禁用 // 登录安全:绑定手机号后强制走「密码 + 短信验证码 + DCAuth 设备签名」。 Phone string `gorm:"size:32;not null;default:''" json:"phone"` PhoneBoundAt *time.Time `json:"phone_bound_at,omitempty"` PhoneBoundBy *uint `json:"phone_bound_by,omitempty"` // 以下字段只用于管理端列表展示,不落库到 users 表。 PhoneMasked string `gorm:"-" json:"phone_masked,omitempty"` DeviceID string `gorm:"-" json:"device_id,omitempty"` DeviceIDMasked string `gorm:"-" json:"device_id_masked,omitempty"` DeviceBound bool `gorm:"-" json:"device_bound"` }