goods.go 3.5 KB

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