30 lines
893 B
Go
30 lines
893 B
Go
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禁用
|
|
}
|