goods.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 GoodsGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. Name string `form:"name" search:"type:contains;column:name;table:goods"` // 商品名称
  10. MediaType string `form:"mediaType" search:"type:contains;column:media_type;table:goods"` // 介质类型
  11. IsShow int `form:"isShow" search:"-"` // 是否展示 1-展示 2-不展示
  12. GoodsOrder
  13. }
  14. type GoodsOrder struct {
  15. CreatedAtOrder string `search:"type:order;column:created_at;table:goods" form:"createdAtOrder" default:"desc"`
  16. }
  17. func (m *GoodsGetPageReq) GetNeedSearch() interface{} {
  18. return *m
  19. }
  20. type GoodsInsertReq struct {
  21. Id int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
  22. Name string `json:"name" vd:"len($)>0;msg:'商品名称不能为空'"` // 商品名称
  23. Price float64 `json:"price"` // 价格
  24. MediaType string `json:"mediaType"` // 介质类型
  25. IsShow bool `json:"isShow"` // 是否显示
  26. ShowStartTime common.Time `json:"showStartTime"` // 展示开始时间
  27. ShowEndTime common.Time `json:"showEndTime"` // 展示结束时间
  28. Img string `json:"img"` // 图片
  29. Remark string `json:"remark"` // 备注
  30. common.ControlBy `swaggerignore:"true"`
  31. common.DeptBy `swaggerignore:"true"`
  32. }
  33. func (s *GoodsInsertReq) Generate(model *model.Goods) {
  34. if s.Id != 0 {
  35. model.Id = s.Id
  36. }
  37. model.Name = s.Name
  38. model.Price = s.Price
  39. model.MediaType = s.MediaType
  40. model.IsShow = s.IsShow
  41. model.ShowStartTime = s.ShowStartTime
  42. model.ShowEndTime = s.ShowEndTime
  43. model.Img = s.Img
  44. model.Remark = s.Remark
  45. if s.ControlBy.UpdateBy != 0 {
  46. model.UpdateBy = s.UpdateBy
  47. }
  48. if s.ControlBy.CreateBy != 0 {
  49. model.CreateBy = s.CreateBy
  50. }
  51. if s.DeptBy.DeptId != 0 {
  52. model.DeptId = s.DeptId
  53. }
  54. }
  55. func (s *GoodsInsertReq) GetId() interface{} {
  56. return s.Id
  57. }
  58. type GoodsUpdateReq struct {
  59. Id int `json:"id" comment:"编码"` // 编码
  60. Name string `json:"name" vd:"len($)>0;msg:'商品名称不能为空'"` // 商品名称
  61. Price float64 `json:"price"` // 价格
  62. MediaType string `json:"mediaType"` // 介质类型
  63. IsShow bool `json:"isShow"` // 是否显示
  64. ShowStartTime common.Time `json:"showStartTime"` // 展示开始时间
  65. ShowEndTime common.Time `json:"showEndTime"` // 展示结束时间
  66. Img string `json:"img"` // 图片
  67. Remark string `json:"remark"` // 备注
  68. common.ControlBy `swaggerignore:"true"`
  69. }
  70. func (s *GoodsUpdateReq) Generate(model *model.Goods) {
  71. if s.Id != 0 {
  72. model.Id = s.Id
  73. }
  74. model.Name = s.Name
  75. model.Price = s.Price
  76. model.MediaType = s.MediaType
  77. model.IsShow = s.IsShow
  78. model.ShowStartTime = s.ShowStartTime
  79. model.ShowEndTime = s.ShowEndTime
  80. model.Img = s.Img
  81. model.Remark = s.Remark
  82. if s.ControlBy.UpdateBy != 0 {
  83. model.UpdateBy = s.UpdateBy
  84. }
  85. if s.ControlBy.CreateBy != 0 {
  86. model.CreateBy = s.CreateBy
  87. }
  88. }
  89. func (s *GoodsUpdateReq) GetId() interface{} {
  90. return s.Id
  91. }
  92. type GoodsGetReq struct {
  93. Id int `uri:"id"`
  94. }
  95. func (s *GoodsGetReq) GetId() interface{} {
  96. return s.Id
  97. }
  98. type GoodsDeleteReq struct {
  99. Id int `json:"id"`
  100. common.ControlBy `swaggerignore:"true"`
  101. }
  102. func (s *GoodsDeleteReq) GetId() interface{} {
  103. return s.Id
  104. }
  105. type AppletGoodsGetPageReq struct {
  106. dto.Pagination `search:"-"`
  107. StoreId int `form:"storeId" search:"type:exact;column:dept_id;table:goods" vd:"$>0;msg:'门店id不能为空'"`
  108. Name string `form:"name" search:"type:contains;column:name;table:goods"` // 商品名称
  109. MediaType string `form:"mediaType" search:"type:contains;column:media_type;table:goods"` // 介质类型
  110. IsShow int `form:"isShow" search:"-"` // 是否展示 1-展示 2-不展示
  111. GoodsOrder
  112. }
  113. func (m *AppletGoodsGetPageReq) GetNeedSearch() interface{} {
  114. return *m
  115. }