customer.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 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. Type int `form:"type" search:"type:exact;column:type;table:sys_user" comment:"累心"`
  12. CustomerOrder
  13. }
  14. type CustomerOrder 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 *CustomerGetPageReq) GetNeedSearch() interface{} {
  21. return *m
  22. }
  23. type ResetCustomerPwdReq 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 *ResetCustomerPwdReq) GetId() interface{} {
  29. return s.Id
  30. }
  31. func (s *ResetCustomerPwdReq) 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 UpdateCustomerStatusReq 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 *UpdateCustomerStatusReq) GetId() interface{} {
  49. return s.Id
  50. }
  51. func (s *UpdateCustomerStatusReq) 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 CustomerInsertReq 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"` // 手机号
  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. // SetCreateBy 设置创建人id
  76. func (e *CustomerInsertReq) SetDeptId(deptId int) {
  77. e.DeptId = deptId
  78. }
  79. func (s *CustomerInsertReq) Generate(userModel *model.SysUser) {
  80. if s.Id != 0 {
  81. userModel.Id = s.Id
  82. }
  83. userModel.Username = s.Username
  84. userModel.Password = s.Password
  85. userModel.NickName = s.Name
  86. userModel.Phone = s.Phone
  87. userModel.DeptId = s.DeptId
  88. userModel.Status = "2"
  89. userModel.Type = 0
  90. userModel.UserType = model.UserTypeCustomer
  91. if s.ControlBy.UpdateBy != 0 {
  92. userModel.UpdateBy = s.UpdateBy
  93. }
  94. if s.ControlBy.CreateBy != 0 {
  95. userModel.CreateBy = s.CreateBy
  96. }
  97. }
  98. func (s *CustomerInsertReq) GetId() interface{} {
  99. return s.Id
  100. }
  101. type CustomerUpdateReq struct {
  102. Id int `json:"id" comment:"用户ID"` // 用户ID
  103. Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
  104. Phone string `json:"phone" swaggerignore:"true"` // 手机号
  105. model2.ControlBy `swaggerignore:"true"`
  106. }
  107. func (s *CustomerUpdateReq) Generate(userModel *model.SysUser) {
  108. if s.Id != 0 {
  109. userModel.Id = s.Id
  110. }
  111. userModel.NickName = s.Name
  112. userModel.Phone = s.Phone
  113. if s.ControlBy.UpdateBy != 0 {
  114. userModel.UpdateBy = s.UpdateBy
  115. }
  116. if s.ControlBy.CreateBy != 0 {
  117. userModel.CreateBy = s.CreateBy
  118. }
  119. }
  120. func (s *CustomerUpdateReq) GetId() interface{} {
  121. return s.Id
  122. }
  123. type CustomerGetReq struct {
  124. Id int `uri:"id"`
  125. }
  126. func (s *CustomerGetReq) GetId() interface{} {
  127. return s.Id
  128. }
  129. type CustomerDeleteReq struct {
  130. Id int `json:"id"`
  131. model2.ControlBy `swaggerignore:"true"`
  132. }
  133. func (s *CustomerDeleteReq) GetId() interface{} {
  134. return s.Id
  135. }
  136. type CustomerById struct {
  137. dto2.ObjectById
  138. model2.ControlBy `swaggerignore:"true"`
  139. }
  140. func (s *CustomerById) GetIds() interface{} {
  141. return s.Ids
  142. }
  143. func (s *CustomerById) GetId() interface{} {
  144. if len(s.Ids) > 0 {
  145. s.Ids = append(s.Ids, s.Id)
  146. return s.Ids
  147. }
  148. return s.Id
  149. }
  150. func (s *CustomerById) GenerateM() (model2.ActiveRecord, error) {
  151. return &model.SysUser{}, nil
  152. }
  153. // PassWord 密码
  154. type CustomerPassWord struct {
  155. NewPassword string `json:"newPassword" example:"123456" vd:"len($)>0"` // 新密码
  156. OldPassword string `json:"oldPassword" example:"12345678" vd:"len($)>0"` // 旧密码
  157. }
  158. type CustomerGetSMSVerifyCodeReq struct {
  159. Phone string `form:"phone" example:"13912345678"` //手机号
  160. }
  161. type CustomerWxLoginReq struct {
  162. Phone string `json:"phone"` // 手机号
  163. Code string `json:"code"` // 密码
  164. }