customer.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 CustomerGetPageReq 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. CustomerOrder
  12. }
  13. type CustomerOrder struct {
  14. //UserIdOrder string `search:"type:order;column:id;table:sys_user" form:"userIdOrder"`
  15. //UsernameOrder string `search:"type:order;column:username;table:sys_user" form:"usernameOrder"`
  16. //StatusOrder string `search:"type:order;column:status;table:sys_user" form:"statusOrder"`
  17. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_user" form:"createdAtOrder" default:"desc"`
  18. }
  19. func (m *CustomerGetPageReq) GetNeedSearch() interface{} {
  20. return *m
  21. }
  22. type ResetCustomerPwdReq struct {
  23. Id int `json:"id" example:"1" vd:"$>0"` // 用户ID
  24. Password string `json:"password" example:"123456" vd:"len($)>0"` // 密码
  25. model2.ControlBy `swaggerignore:"true"`
  26. }
  27. func (s *ResetCustomerPwdReq) GetId() interface{} {
  28. return s.Id
  29. }
  30. func (s *ResetCustomerPwdReq) Generate(userModel *model.SysUser) {
  31. if s.Id != 0 {
  32. userModel.Id = s.Id
  33. }
  34. userModel.Password = s.Password
  35. if s.ControlBy.UpdateBy != 0 {
  36. userModel.UpdateBy = s.UpdateBy
  37. }
  38. if s.ControlBy.CreateBy != 0 {
  39. userModel.CreateBy = s.CreateBy
  40. }
  41. }
  42. type UpdateCustomerStatusReq struct {
  43. Id int `json:"id" example:"1" vd:"$>0"` // 用户ID
  44. Status string `json:"status" example:"2" vd:"len($)>0"` // 状态 1-停用 2-正常
  45. model2.ControlBy `swaggerignore:"true"`
  46. }
  47. func (s *UpdateCustomerStatusReq) GetId() interface{} {
  48. return s.Id
  49. }
  50. func (s *UpdateCustomerStatusReq) Generate(userModel *model.SysUser) {
  51. if s.Id != 0 {
  52. userModel.Id = s.Id
  53. }
  54. userModel.Status = s.Status
  55. if s.ControlBy.UpdateBy != 0 {
  56. userModel.UpdateBy = s.UpdateBy
  57. }
  58. if s.ControlBy.CreateBy != 0 {
  59. userModel.CreateBy = s.CreateBy
  60. }
  61. }
  62. type CustomerInsertReq struct {
  63. Id int `json:"id" swaggerignore:"true" comment:"用户ID"` // 用户ID
  64. Username string `json:"username" example:"username" vd:"@:len($)>0;msg:'用户名不能为空'"` // 用户名
  65. Password string `json:"password" example:"123456" vd:"@:len($)>5;msg:'密码格式不正确'"` // 密码
  66. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  67. Phone string `json:"phone"` // 手机号
  68. RoleId int `json:"roleId" example:"1" swaggerignore:"true"` // 角色id
  69. DeptId int `json:"deptId" example:"1"` // 机构id
  70. Status string `json:"status" example:"2" swaggerignore:"true"` // 状态 // 货车司机绑定《道路运输从业人员从业资格证》信息
  71. Type int `json:"type" example:"2"` // 管理员1 仓管2 司机3
  72. model2.ControlBy `swaggerignore:"true"`
  73. }
  74. // SetCreateBy 设置创建人id
  75. func (e *CustomerInsertReq) SetDeptId(deptId int) {
  76. e.DeptId = deptId
  77. }
  78. func (s *CustomerInsertReq) Generate(userModel *model.SysUser) {
  79. if s.Id != 0 {
  80. userModel.Id = s.Id
  81. }
  82. userModel.Username = s.Username
  83. userModel.Password = s.Password
  84. userModel.NickName = s.Name
  85. userModel.Phone = s.Phone
  86. userModel.DeptId = s.DeptId
  87. userModel.Status = "2"
  88. userModel.Type = 0
  89. userModel.UserType = model.UserTypeCustomer
  90. if s.ControlBy.UpdateBy != 0 {
  91. userModel.UpdateBy = s.UpdateBy
  92. }
  93. if s.ControlBy.CreateBy != 0 {
  94. userModel.CreateBy = s.CreateBy
  95. }
  96. }
  97. func (s *CustomerInsertReq) GetId() interface{} {
  98. return s.Id
  99. }
  100. type CustomerUpdateReq struct {
  101. Id int `json:"id" comment:"用户ID"` // 用户ID
  102. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  103. Phone string `json:"phone" swaggerignore:"true"` // 手机号
  104. model2.ControlBy `swaggerignore:"true"`
  105. }
  106. func (s *CustomerUpdateReq) Generate(userModel *model.SysUser) {
  107. if s.Id != 0 {
  108. userModel.Id = s.Id
  109. }
  110. userModel.NickName = s.Name
  111. userModel.Phone = s.Phone
  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 *CustomerUpdateReq) GetId() interface{} {
  120. return s.Id
  121. }
  122. type CustomerGetReq struct {
  123. Id int `uri:"id"`
  124. }
  125. func (s *CustomerGetReq) GetId() interface{} {
  126. return s.Id
  127. }
  128. type CustomerDeleteReq struct {
  129. Id int `json:"id"`
  130. model2.ControlBy `swaggerignore:"true"`
  131. }
  132. func (s *CustomerDeleteReq) GetId() interface{} {
  133. return s.Id
  134. }
  135. type CustomerById struct {
  136. dto2.ObjectById
  137. model2.ControlBy `swaggerignore:"true"`
  138. }
  139. func (s *CustomerById) GetIds() interface{} {
  140. return s.Ids
  141. }
  142. func (s *CustomerById) 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 *CustomerById) GenerateM() (model2.ActiveRecord, error) {
  150. return &model.SysUser{}, nil
  151. }
  152. // PassWord 密码
  153. type CustomerPassWord struct {
  154. NewPassword string `json:"newPassword" example:"123456" vd:"len($)>0"` // 新密码
  155. OldPassword string `json:"oldPassword" example:"12345678" vd:"len($)>0"` // 旧密码
  156. }
  157. type CustomerGetSMSVerifyCodeReq struct {
  158. Phone string `form:"phone" example:"13912345678"` //手机号
  159. }
  160. type CustomerWxLoginReq struct {
  161. Phone string `json:"phone"` // 手机号
  162. Code string `json:"code"` // 密码
  163. }