sys_user.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. "go-admin/common/dto"
  5. common "go-admin/common/models"
  6. )
  7. type SysUserGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. UserId int `form:"userId" search:"type:exact;column:user_id;table:sys_user" comment:"用户ID"`
  10. Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
  11. NickName string `form:"nickName" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
  12. Phone string `form:"phone" search:"type:contains;column:phone;table:sys_user" comment:"手机号"`
  13. RoleId string `form:"roleId" search:"type:exact;column:role_id;table:sys_user" comment:"角色ID"`
  14. Sex string `form:"sex" search:"type:exact;column:sex;table:sys_user" comment:"性别"`
  15. Email string `form:"email" search:"type:contains;column:email;table:sys_user" comment:"邮箱"`
  16. PostId string `form:"postId" search:"type:exact;column:post_id;table:sys_user" comment:"岗位"`
  17. Status string `form:"status" search:"type:exact;column:status;table:sys_user" comment:"状态"`
  18. DeptJoin `search:"type:left;on:dept_id:dept_id;table:sys_user;join:sys_dept"`
  19. SysUserOrder
  20. }
  21. type SysUserOrder struct {
  22. UserIdOrder string `search:"type:order;column:user_id;table:sys_user" form:"userIdOrder"`
  23. UsernameOrder string `search:"type:order;column:username;table:sys_user" form:"usernameOrder"`
  24. StatusOrder string `search:"type:order;column:status;table:sys_user" form:"statusOrder"`
  25. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_user" form:"createdAtOrder"`
  26. }
  27. type DeptJoin struct {
  28. DeptId string `search:"type:contains;column:dept_path;table:sys_dept" form:"deptId"`
  29. }
  30. func (m *SysUserGetPageReq) GetNeedSearch() interface{} {
  31. return *m
  32. }
  33. type ResetSysUserPwdReq struct {
  34. UserId int `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
  35. Password string `json:"password" comment:"密码" vd:"len($)>0"`
  36. common.ControlBy
  37. }
  38. func (s *ResetSysUserPwdReq) GetId() interface{} {
  39. return s.UserId
  40. }
  41. func (s *ResetSysUserPwdReq) Generate(model *models.SysUser) {
  42. if s.UserId != 0 {
  43. model.UserId = s.UserId
  44. }
  45. model.Password = s.Password
  46. }
  47. type UpdateSysUserAvatarReq struct {
  48. UserId int `json:"userId" comment:"用户ID" vd:"len($)>0"` // 用户ID
  49. Avatar string `json:"avatar" comment:"头像" vd:"len($)>0"`
  50. common.ControlBy
  51. }
  52. func (s *UpdateSysUserAvatarReq) GetId() interface{} {
  53. return s.UserId
  54. }
  55. func (s *UpdateSysUserAvatarReq) Generate(model *models.SysUser) {
  56. if s.UserId != 0 {
  57. model.UserId = s.UserId
  58. }
  59. model.Avatar = s.Avatar
  60. }
  61. type UpdateSysUserStatusReq struct {
  62. UserId int `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
  63. Status string `json:"status" comment:"状态" vd:"len($)>0"`
  64. common.ControlBy
  65. }
  66. func (s *UpdateSysUserStatusReq) GetId() interface{} {
  67. return s.UserId
  68. }
  69. func (s *UpdateSysUserStatusReq) Generate(model *models.SysUser) {
  70. if s.UserId != 0 {
  71. model.UserId = s.UserId
  72. }
  73. model.Status = s.Status
  74. }
  75. type SysUserInsertReq struct {
  76. UserId int `json:"userId" comment:"用户ID"` // 用户ID
  77. Username string `json:"username" comment:"用户名" vd:"len($)>0"`
  78. Password string `json:"password" comment:"密码"`
  79. NickName string `json:"nickName" comment:"昵称" vd:"len($)>0"`
  80. Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
  81. RoleId int `json:"roleId" comment:"角色ID"`
  82. Avatar string `json:"avatar" comment:"头像"`
  83. Sex string `json:"sex" comment:"性别"`
  84. Email string `json:"email" comment:"邮箱"` // vd:"len($)>0,email"
  85. DeptId int `json:"deptId" comment:"部门" vd:"$>0"`
  86. PostId int `json:"postId" comment:"岗位"`
  87. Remark string `json:"remark" comment:"备注"`
  88. Status string `json:"status" comment:"状态" vd:"len($)>0" default:"1"`
  89. common.ControlBy
  90. }
  91. func (s *SysUserInsertReq) Generate(model *models.SysUser) {
  92. if s.UserId != 0 {
  93. model.UserId = s.UserId
  94. }
  95. model.Username = s.Username
  96. model.Password = s.Password
  97. model.NickName = s.NickName
  98. model.Phone = s.Phone
  99. model.RoleId = s.RoleId
  100. model.Avatar = s.Avatar
  101. model.Sex = s.Sex
  102. model.Email = s.Email
  103. model.DeptId = s.DeptId
  104. model.PostId = s.PostId
  105. model.Remark = s.Remark
  106. model.Status = s.Status
  107. model.CreateBy = s.CreateBy
  108. }
  109. func (s *SysUserInsertReq) GetId() interface{} {
  110. return s.UserId
  111. }
  112. type SysUserUpdateReq struct {
  113. UserId int `json:"userId" comment:"用户ID"` // 用户ID
  114. Username string `json:"username" comment:"用户名" vd:"len($)>0"`
  115. NickName string `json:"nickName" comment:"昵称" vd:"len($)>0"`
  116. Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
  117. RoleId int `json:"roleId" comment:"角色ID"`
  118. Avatar string `json:"avatar" comment:"头像"`
  119. Sex string `json:"sex" comment:"性别"`
  120. Email string `json:"email" comment:"邮箱"` // vd:"len($)>0,email"
  121. DeptId int `json:"deptId" comment:"部门" vd:"$>0"`
  122. PostId int `json:"postId" comment:"岗位"`
  123. Remark string `json:"remark" comment:"备注"`
  124. Status string `json:"status" comment:"状态" default:"1"`
  125. common.ControlBy
  126. }
  127. func (s *SysUserUpdateReq) Generate(model *models.SysUser) {
  128. if s.UserId != 0 {
  129. model.UserId = s.UserId
  130. }
  131. model.Username = s.Username
  132. model.NickName = s.NickName
  133. model.Phone = s.Phone
  134. model.RoleId = s.RoleId
  135. model.Avatar = s.Avatar
  136. model.Sex = s.Sex
  137. model.Email = s.Email
  138. model.DeptId = s.DeptId
  139. model.PostId = s.PostId
  140. model.Remark = s.Remark
  141. model.Status = s.Status
  142. }
  143. func (s *SysUserUpdateReq) GetId() interface{} {
  144. return s.UserId
  145. }
  146. type SysUserById struct {
  147. dto.ObjectById
  148. common.ControlBy
  149. }
  150. func (s *SysUserById) GetId() interface{} {
  151. if len(s.Ids) > 0 {
  152. s.Ids = append(s.Ids, s.Id)
  153. return s.Ids
  154. }
  155. return s.Id
  156. }
  157. func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
  158. return &models.SysUser{}, nil
  159. }
  160. // PassWord 密码
  161. type PassWord struct {
  162. NewPassword string `json:"newPassword" vd:"len($)>0"`
  163. OldPassword string `json:"oldPassword" vd:"len($)>0"`
  164. }