sys_user.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. Status string `json:"status" example:"2" swaggerignore:"true"` // 状态 // 货车司机绑定《道路运输从业人员从业资格证》信息
  83. Type int `json:"type" example:"2"` // 管理员1 门店管理员2 配送员3
  84. model2.ControlBy `swaggerignore:"true"`
  85. }
  86. func (s *SysUserInsertReq) Generate(userModel *model.SysUser) {
  87. if s.Id != 0 {
  88. userModel.Id = s.Id
  89. }
  90. userModel.Username = s.Username
  91. userModel.Password = s.Password
  92. userModel.NickName = s.Name
  93. userModel.Phone = s.Phone
  94. userModel.DeptId = s.DeptId
  95. userModel.RoleId = s.RoleId
  96. userModel.Status = "2"
  97. userModel.Type = s.Type
  98. userModel.UserType = model.UserTypeSys
  99. if s.ControlBy.UpdateBy != 0 {
  100. userModel.UpdateBy = s.UpdateBy
  101. }
  102. if s.ControlBy.CreateBy != 0 {
  103. userModel.CreateBy = s.CreateBy
  104. }
  105. }
  106. func (s *SysUserInsertReq) GetId() interface{} {
  107. return s.Id
  108. }
  109. type SysUserUpdateReq struct {
  110. Id int `json:"id" comment:"用户ID"` // 用户ID
  111. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  112. Phone string `json:"phone"` // 电话号码
  113. Type int `json:"type" example:"2"` // 管理员1 仓管2 司机3
  114. model2.ControlBy `swaggerignore:"true"`
  115. }
  116. func (s *SysUserUpdateReq) Generate(userModel *model.SysUser) {
  117. if s.Id != 0 {
  118. userModel.Id = s.Id
  119. }
  120. userModel.NickName = s.Name
  121. userModel.Phone = s.Phone
  122. userModel.Type = s.Type
  123. if s.ControlBy.UpdateBy != 0 {
  124. userModel.UpdateBy = s.UpdateBy
  125. }
  126. if s.ControlBy.CreateBy != 0 {
  127. userModel.CreateBy = s.CreateBy
  128. }
  129. }
  130. func (s *SysUserUpdateReq) GetId() interface{} {
  131. return s.Id
  132. }
  133. type SysUserGetReq struct {
  134. Id int `uri:"id"`
  135. }
  136. func (s *SysUserGetReq) GetId() interface{} {
  137. return s.Id
  138. }
  139. type SysUserDeleteReq struct {
  140. Id int `json:"id"`
  141. model2.ControlBy `swaggerignore:"true"`
  142. }
  143. func (s *SysUserDeleteReq) GetId() interface{} {
  144. return s.Id
  145. }
  146. type SysUserById struct {
  147. dto2.ObjectById
  148. model2.ControlBy `swaggerignore:"true"`
  149. }
  150. func (s *SysUserById) GetIds() interface{} {
  151. return s.Ids
  152. }
  153. func (s *SysUserById) GetId() interface{} {
  154. if len(s.Ids) > 0 {
  155. s.Ids = append(s.Ids, s.Id)
  156. return s.Ids
  157. }
  158. return s.Id
  159. }
  160. func (s *SysUserById) GenerateM() (model2.ActiveRecord, error) {
  161. return &model.SysUser{}, nil
  162. }
  163. // PassWord 密码
  164. type SysUserPassWord struct {
  165. NewPassword string `json:"newPassword" example:"123456" vd:"len($)>0"` // 新密码
  166. OldPassword string `json:"oldPassword" example:"12345678" vd:"len($)>0"` // 旧密码
  167. }
  168. type SysUserGetSMSVerifyCodeReq struct {
  169. Phone string `form:"phone" example:"13912345678"` //手机号
  170. }