customer.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package dto
  2. import (
  3. "gas-cylinder-api/app/admin/model"
  4. "gas-cylinder-api/common/dto"
  5. common "gas-cylinder-api/common/model"
  6. )
  7. type CustomerGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. PrincipalPhone string `form:"principalPhone" search:"type:contains;column:principal_phone;table:customer"` // 电话
  10. Type string `form:"type" search:"type:exact;column:type;table:customer"` // 类型
  11. Address string `form:"address" search:"type:contains;column:address;table:customer"` // 地址
  12. CustomerOrder
  13. }
  14. type CustomerOrder struct {
  15. CreatedAtOrder string `search:"type:order;column:created_at;table:customer" form:"createdAtOrder" default:"desc"`
  16. }
  17. func (m *CustomerGetPageReq) GetNeedSearch() interface{} {
  18. return *m
  19. }
  20. type CustomerInsertReq struct {
  21. Id string `json:"id" swaggerignore:"true"` // 主键ID
  22. Name string `json:"name"` // 名字
  23. PrincipalPhone string `json:"principalPhone" vd:"len($)>0;msg:'电话不能为空'"` // 负责人电话
  24. Address string `json:"address"` // 地址
  25. AddressImg string `json:"addressImg"` // 现场图片
  26. Lng float64 `json:"lng"` // 经度
  27. Lat float64 `json:"lat"` // 纬度
  28. Type int `json:"type"` // 类型 0-商户 1-私人
  29. City string `json:"city"` // 所在地市
  30. Area string `json:"area"` // 所属区/县
  31. Remark string `json:"remark"` // 备注描述
  32. StoreCode string `swaggerignore:"true"` // 门店登记编号
  33. common.ControlBy `swaggerignore:"true"`
  34. common.DeptBy `swaggerignore:"true"`
  35. }
  36. func (s *CustomerInsertReq) Generate(model *model.Customer) {
  37. model.Name = s.Name
  38. if s.Type == 0 {
  39. model.ShopName = s.Name
  40. }
  41. if s.Type == 1 {
  42. model.PrincipalName = s.Name
  43. }
  44. model.PrincipalPhone = s.PrincipalPhone
  45. model.Address = s.Address
  46. if len(s.AddressImg) > 0 {
  47. model.AddressImg = s.AddressImg
  48. }
  49. model.Lng = s.Lng
  50. model.Lat = s.Lat
  51. model.Type = s.Type
  52. model.City = s.City
  53. model.Area = s.Area
  54. model.Remark = s.Remark
  55. model.StoreCode = s.StoreCode
  56. if s.ControlBy.UpdateBy != 0 {
  57. model.UpdateBy = s.UpdateBy
  58. }
  59. if s.ControlBy.CreateBy != 0 {
  60. model.CreateBy = s.CreateBy
  61. }
  62. if s.DeptBy.DeptId != 0 {
  63. model.DeptId = s.DeptId
  64. }
  65. }
  66. func (s *CustomerInsertReq) GetId() interface{} {
  67. return s.Id
  68. }
  69. func (s *CustomerInsertReq) SetStoreCode(storeCode string) {
  70. s.StoreCode = storeCode
  71. }
  72. type CustomerUpdateReq struct {
  73. Id string `json:"id" vd:"len($)>0"` // 主键ID
  74. Name string `json:"name"` // 名字
  75. PrincipalPhone string `json:"principalPhone" vd:"len($)>0;msg:'电话不能为空'"` // 负责人电话
  76. Address string `json:"address"` // 地址
  77. AddressImg string `json:"addressImg"` // 现场图片
  78. Lng float64 `json:"lng"` // 经度
  79. Lat float64 `json:"lat"` // 纬度
  80. Type int `json:"type"` // 类型 0-商户 1-私人
  81. City string `json:"city"` // 所在地市
  82. Area string `json:"area"` // 所属区/县
  83. Remark string `json:"remark"` // 备注描述
  84. StoreCode string `swaggerignore:"true"` // 门店登记编号
  85. common.ControlBy `swaggerignore:"true"`
  86. common.DeptBy `swaggerignore:"true"`
  87. }
  88. func (s *CustomerUpdateReq) Generate(model *model.Customer) {
  89. model.Name = s.Name
  90. if s.Type == 0 {
  91. model.ShopName = s.Name
  92. }
  93. if s.Type == 1 {
  94. model.PrincipalName = s.Name
  95. }
  96. model.PrincipalPhone = s.PrincipalPhone
  97. model.Address = s.Address
  98. model.AddressImg = s.AddressImg
  99. model.Lng = s.Lng
  100. model.Lat = s.Lat
  101. model.Type = s.Type
  102. model.City = s.City
  103. model.Area = s.Area
  104. model.Remark = s.Remark
  105. model.StoreCode = s.StoreCode
  106. if s.ControlBy.UpdateBy != 0 {
  107. model.UpdateBy = s.UpdateBy
  108. }
  109. if s.ControlBy.CreateBy != 0 {
  110. model.CreateBy = s.CreateBy
  111. }
  112. }
  113. func (s *CustomerUpdateReq) GetId() interface{} {
  114. return s.Id
  115. }
  116. type CustomerGetReq struct {
  117. Id string `uri:"id"`
  118. }
  119. func (s *CustomerGetReq) GetId() interface{} {
  120. return s.Id
  121. }
  122. type CustomerGetByPhoneReq struct {
  123. Phone string `form:"phone" vd:"len($)>0"`
  124. }
  125. type CustomerGetBorrowGasCylinderReq struct {
  126. CustomerId string `form:"customerId" vd:"len($)>0"`
  127. }
  128. type CustomerDeleteReq struct {
  129. Id string `json:"id" vd:"len($)>0"`
  130. common.ControlBy `swaggerignore:"true"`
  131. }
  132. func (s *CustomerDeleteReq) GetId() interface{} {
  133. return s.Id
  134. }