sys_user.go 5.6 KB

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