address.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 AddressGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. CustomerId string `form:"customerId" search:"type:contains;column:customer_id;table:address"` // 角色名称
  10. AddressOrder
  11. }
  12. type AddressOrder struct {
  13. CreatedAtOrder string `search:"type:order;column:created_at;table:address" form:"createdAtOrder" default:"desc"`
  14. }
  15. func (m *AddressGetPageReq) GetNeedSearch() interface{} {
  16. return *m
  17. }
  18. type AddressInsertReq struct {
  19. Id int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
  20. CustomerId string `json:"customerId" swaggerignore:"true"` // 客户id
  21. Name string `json:"name"` // 收货人名称
  22. Phone string `json:"phone" vd:"len($)>0;msg:'手机号不能为空'"` // 联系电话
  23. City string `json:"city" vd:"len($)>0;msg:'所在地市不能为空'"` // 所在地市
  24. Area string `json:"area" vd:"len($)>0;msg:'所属区/县不能为空'"` // 所属区/县
  25. Address string `json:"address"` // 详细地址
  26. IsDefault bool `json:"isDefault"` // 默认地址
  27. Lng float64 `json:"lng"` // 经度
  28. Lat float64 `json:"lat"` // 纬度
  29. }
  30. func (s *AddressInsertReq) Generate(m *model.Address) {
  31. if s.Id != 0 {
  32. m.Id = s.Id
  33. }
  34. m.CustomerId = s.CustomerId
  35. m.Name = s.Name
  36. m.Phone = s.Phone
  37. m.City = s.City
  38. m.Area = s.Area
  39. m.Address = s.Address
  40. m.IsDefault = s.IsDefault
  41. m.Lng = s.Lng
  42. m.Lat = s.Lat
  43. }
  44. func (e *AddressInsertReq) SetCustomerId(CustomerId string) {
  45. e.CustomerId = CustomerId
  46. }
  47. func (s *AddressInsertReq) GetId() interface{} {
  48. return s.Id
  49. }
  50. type AddressUpdateReq struct {
  51. Id int `json:"id" comment:"编码"` // 编码
  52. Name string `json:"name"` // 收货人名称
  53. Phone string `json:"phone"` // 联系电话
  54. City string `json:"city"` // 所在地市
  55. Area string `json:"area"` // 所属区/县
  56. Address string `json:"address"` // 详细地址
  57. IsDefault bool `json:"isDefault"` // 默认地址
  58. Lng float64 `json:"lng"` // 经度
  59. Lat float64 `json:"lat"` // 纬度
  60. common.ControlBy `swaggerignore:"true"`
  61. }
  62. func (s *AddressUpdateReq) Generate(m *model.Address) {
  63. if s.Id != 0 {
  64. m.Id = s.Id
  65. }
  66. m.Name = s.Name
  67. m.Phone = s.Phone
  68. m.City = s.City
  69. m.Area = s.Area
  70. m.Address = s.Address
  71. m.IsDefault = s.IsDefault
  72. m.Lng = s.Lng
  73. m.Lat = s.Lat
  74. if s.ControlBy.UpdateBy != 0 {
  75. m.UpdateBy = s.UpdateBy
  76. }
  77. if s.ControlBy.CreateBy != 0 {
  78. m.CreateBy = s.CreateBy
  79. }
  80. }
  81. func (s *AddressUpdateReq) GetId() interface{} {
  82. return s.Id
  83. }
  84. type AddressGetReq struct {
  85. Id int `uri:"id"`
  86. }
  87. func (s *AddressGetReq) GetId() interface{} {
  88. return s.Id
  89. }
  90. type AddressDeleteReq struct {
  91. Id int `json:"id"`
  92. common.ControlBy `swaggerignore:"true"`
  93. }
  94. func (s *AddressDeleteReq) GetId() interface{} {
  95. return s.Id
  96. }