user.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package handler
  2. import (
  3. "git.cestong.com.cn/cecf/config-center-server/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. DeptId int `json:"deptId" 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. DeptIds []int `json:"deptIds" gorm:"-"`
  22. PostIds []int `json:"postIds" gorm:"-"`
  23. RoleIds []int `json:"roleIds" gorm:"-"`
  24. //Dept *SysDept `json:"dept"`
  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.DeptIds = []int{e.DeptId}
  33. e.PostIds = []int{e.PostId}
  34. e.RoleIds = []int{e.RoleId}
  35. return nil
  36. }