user.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package models
  2. import (
  3. "IotAdmin/common/models"
  4. "gorm.io/gorm"
  5. )
  6. type SysUser struct {
  7. UserId int `gorm:"primaryKey;autoIncrement;comment:编码" json:"userId"`
  8. Username string `json:"username" gorm:"size:64;comment:用户名"`
  9. Password string `json:"-" gorm:"size:128;comment:密码"`
  10. NickName string `json:"nickName" gorm:"size:128;comment:昵称"`
  11. Phone string `json:"phone" gorm:"size:11;comment:手机号"`
  12. RoleId int `json:"roleId" gorm:"size:20;comment:角色ID"`
  13. Salt string `json:"-" gorm:"size:255;comment:加盐"`
  14. Avatar string `json:"avatar" gorm:"size:255;comment:头像"`
  15. Sex string `json:"sex" gorm:"size:255;comment:性别"`
  16. Email string `json:"email" gorm:"size:128;comment:邮箱"`
  17. OrgId int `json:"orgId" gorm:"size:20;comment:部门"`
  18. PostId int `json:"postId" gorm:"size:20;comment:岗位"`
  19. Remark string `json:"remark" gorm:"size:255;comment:备注"`
  20. Status string `json:"status" gorm:"size:4;comment:状态"`
  21. OrgIds []int `json:"orgIds" gorm:"-"`
  22. PostIds []int `json:"postIds" gorm:"-"`
  23. RoleIds []int `json:"roleIds" gorm:"-"`
  24. Org *SysOrg `json:"org"`
  25. models.ControlBy
  26. models.ModelTime
  27. }
  28. func (*SysUser) TableName() string {
  29. return "sys_user"
  30. }
  31. func (e *SysUser) AfterFind(_ *gorm.DB) error {
  32. e.OrgIds = []int{e.OrgId}
  33. e.PostIds = []int{e.PostId}
  34. e.RoleIds = []int{e.RoleId}
  35. return nil
  36. }