123456789101112131415161718192021222324252627282930313233343536373839 |
- package model
- import (
- "os"
- "time"
- "gorm.io/gorm"
- )
- const (
- UserStatusEnable = 1 // 用户状态正常
- UserStatusDisable = 2 // 用户状态禁用
- UserIsSuperTrue = 1 // 用户是超级管理员
- UserIsSuperFalse = 2 // 用户不是超级管理员
- )
- type User struct {
- ID int64 `gorm:"type:int(20);autoIncrement;comment:ID;" json:"id"`
- Account string `gorm:"type:varchar(255);comment:账号;" json:"account"`
- Password string `gorm:"type:varchar(255);comment:密码;" json:"password"`
- Nickname string `gorm:"type:varchar(255);comment:昵称;default:'';" json:"nickname"`
- Status int `gorm:"type:int(1);comment:状态;default:2;" json:"status"`
- IsSuper int `gorm:"type:int(1);comment:是否超级管理员;default:2;" json:"isSuper"`
- Remark string `gorm:"type:varchar(255);comment:备注;default:'';" json:"remark"`
- Roles []Role `gorm:"many2many:user_role;" json:"roles"`
- DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"-"`
- CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
- UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
- }
- func (u *User) AfterFind(tx *gorm.DB) (err error) {
- return
- }
- func (u *User) TableName() string {
- dbPrefix := os.Getenv("DB_PREFIX")
- return dbPrefix + "user"
- }
|