sys_user.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. package dto
  2. import (
  3. "cold-delivery/app/admin/model"
  4. dto2 "cold-delivery/common/dto"
  5. model2 "cold-delivery/common/model"
  6. )
  7. type SysUserGetPageReq struct {
  8. dto2.Pagination `search:"-"`
  9. Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
  10. Name string `form:"name" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
  11. Type int `form:"type" search:"type:exact;column:type;table:sys_user" comment:"状态"`
  12. SysUserOrder
  13. }
  14. type SysUserOrder struct {
  15. //UserIdOrder string `search:"type:order;column:id;table:sys_user" form:"userIdOrder"`
  16. //UsernameOrder string `search:"type:order;column:username;table:sys_user" form:"usernameOrder"`
  17. //StatusOrder string `search:"type:order;column:status;table:sys_user" form:"statusOrder"`
  18. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_user" form:"createdAtOrder" default:"desc"`
  19. }
  20. type SysUserGetPageByDeptIdReq struct {
  21. dto2.Pagination `search:"-"`
  22. Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
  23. Name string `form:"name" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
  24. Type int `form:"type" search:"type:exact;column:type;table:sys_user" comment:"类型"`
  25. CompanyId int `form:"companyId" search:"-" comment:"公司id"`
  26. SysUserOrder
  27. }
  28. func (m *SysUserGetPageReq) GetNeedSearch() interface{} {
  29. return *m
  30. }
  31. func (m *SysUserGetPageByDeptIdReq) GetNeedSearch() interface{} {
  32. return *m
  33. }
  34. type ResetSysUserPwdReq struct {
  35. Id int `json:"id" example:"1" vd:"$>0"` // 用户ID
  36. Password string `json:"password" example:"123456" vd:"len($)>0"` // 密码
  37. model2.ControlBy `swaggerignore:"true"`
  38. }
  39. func (s *ResetSysUserPwdReq) GetId() interface{} {
  40. return s.Id
  41. }
  42. func (s *ResetSysUserPwdReq) Generate(userModel *model.SysUser) {
  43. if s.Id != 0 {
  44. userModel.Id = s.Id
  45. }
  46. userModel.Password = s.Password
  47. if s.ControlBy.UpdateBy != 0 {
  48. userModel.UpdateBy = s.UpdateBy
  49. }
  50. if s.ControlBy.CreateBy != 0 {
  51. userModel.CreateBy = s.CreateBy
  52. }
  53. }
  54. type UpdateSysUserStatusReq struct {
  55. Id int `json:"id" example:"1" vd:"$>0"` // 用户ID
  56. Status string `json:"status" example:"2" vd:"len($)>0"` // 状态 1-停用 2-正常
  57. model2.ControlBy `swaggerignore:"true"`
  58. }
  59. func (s *UpdateSysUserStatusReq) GetId() interface{} {
  60. return s.Id
  61. }
  62. func (s *UpdateSysUserStatusReq) Generate(userModel *model.SysUser) {
  63. if s.Id != 0 {
  64. userModel.Id = s.Id
  65. }
  66. userModel.Status = s.Status
  67. if s.ControlBy.UpdateBy != 0 {
  68. userModel.UpdateBy = s.UpdateBy
  69. }
  70. if s.ControlBy.CreateBy != 0 {
  71. userModel.CreateBy = s.CreateBy
  72. }
  73. }
  74. type SysUserInsertReq struct {
  75. Id int `json:"id" swaggerignore:"true" comment:"用户ID"` // 用户ID
  76. Username string `json:"username" example:"username" vd:"@:len($)>0;msg:'用户名不能为空'"` // 用户名
  77. Password string `json:"password" example:"123456" vd:"@:len($)>5;msg:'密码格式不正确'"` // 密码
  78. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  79. Phone string `json:"phone" vd:"regexp('^1[3-9]\\d{9}$');msg:'电话号码格式不正确'"` // 电话号码
  80. RoleId int `json:"roleId" example:"1" swaggerignore:"true"` // 角色id
  81. DeptId int `json:"deptId" example:"1"` // 机构id
  82. PostId int `json:"postId" example:"1"` // 岗位ID
  83. Status string `json:"status" example:"2" swaggerignore:"true"` // 状态 // 货车司机绑定《道路运输从业人员从业资格证》信息
  84. Type int `json:"type" example:"2"` // 管理员1 门店管理员2 配送员3
  85. model2.ControlBy `swaggerignore:"true"`
  86. }
  87. func (s *SysUserInsertReq) Generate(userModel *model.SysUser) {
  88. if s.Id != 0 {
  89. userModel.Id = s.Id
  90. }
  91. userModel.Username = s.Username
  92. userModel.Password = s.Password
  93. userModel.NickName = s.Name
  94. userModel.Phone = s.Phone
  95. userModel.DeptId = s.DeptId
  96. userModel.RoleId = s.RoleId
  97. userModel.PostId = s.PostId
  98. userModel.Status = "2"
  99. userModel.Type = s.Type
  100. userModel.UserType = model.UserTypeSys
  101. if s.ControlBy.UpdateBy != 0 {
  102. userModel.UpdateBy = s.UpdateBy
  103. }
  104. if s.ControlBy.CreateBy != 0 {
  105. userModel.CreateBy = s.CreateBy
  106. }
  107. }
  108. func (s *SysUserInsertReq) GetId() interface{} {
  109. return s.Id
  110. }
  111. type SysUserUpdateReq struct {
  112. Id int `json:"id" comment:"用户ID"` // 用户ID
  113. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  114. Phone string `json:"phone"` // 电话号码
  115. PostId int `json:"postId" example:"1"` // 岗位ID
  116. Type int `json:"type" example:"2"` // 管理员1 仓管2 司机3
  117. model2.ControlBy `swaggerignore:"true"`
  118. }
  119. func (s *SysUserUpdateReq) Generate(userModel *model.SysUser) {
  120. if s.Id != 0 {
  121. userModel.Id = s.Id
  122. }
  123. userModel.NickName = s.Name
  124. userModel.Phone = s.Phone
  125. userModel.PostId = s.PostId
  126. userModel.Type = s.Type
  127. if s.ControlBy.UpdateBy != 0 {
  128. userModel.UpdateBy = s.UpdateBy
  129. }
  130. if s.ControlBy.CreateBy != 0 {
  131. userModel.CreateBy = s.CreateBy
  132. }
  133. }
  134. func (s *SysUserUpdateReq) GetId() interface{} {
  135. return s.Id
  136. }
  137. type SysUserGetReq struct {
  138. Id int `uri:"id"`
  139. }
  140. func (s *SysUserGetReq) GetId() interface{} {
  141. return s.Id
  142. }
  143. type SysUserDeleteReq struct {
  144. Id int `json:"id"`
  145. model2.ControlBy `swaggerignore:"true"`
  146. }
  147. func (s *SysUserDeleteReq) GetId() interface{} {
  148. return s.Id
  149. }
  150. type SysUserById struct {
  151. dto2.ObjectById
  152. model2.ControlBy `swaggerignore:"true"`
  153. }
  154. func (s *SysUserById) GetIds() interface{} {
  155. return s.Ids
  156. }
  157. func (s *SysUserById) GetId() interface{} {
  158. if len(s.Ids) > 0 {
  159. s.Ids = append(s.Ids, s.Id)
  160. return s.Ids
  161. }
  162. return s.Id
  163. }
  164. func (s *SysUserById) GenerateM() (model2.ActiveRecord, error) {
  165. return &model.SysUser{}, nil
  166. }
  167. // PassWord 密码
  168. type SysUserPassWord struct {
  169. NewPassword string `json:"newPassword" example:"123456" vd:"len($)>0"` // 新密码
  170. OldPassword string `json:"oldPassword" example:"12345678" vd:"len($)>0"` // 旧密码
  171. }
  172. type SysUserGetSMSVerifyCodeReq struct {
  173. Phone string `form:"phone" example:"13912345678"` //手机号
  174. }