device.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 DeviceGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. Sn string `form:"sn" search:"type:contains;column:sn;table:device"` // 设备编码
  10. DeviceOrder
  11. }
  12. type DeviceOrder struct {
  13. CreatedAtOrder string `search:"type:order;column:created_at;table:device" form:"createdAtOrder" default:"desc"`
  14. }
  15. func (m *DeviceGetPageReq) GetNeedSearch() interface{} {
  16. return *m
  17. }
  18. type DeviceInsertReq struct {
  19. Id int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
  20. ProvUserId string `json:"provUserId" gorm:"size:32;"` // 省平台用户id
  21. ProvCmpCode string `json:"provCmpCode" gorm:"size:48;" swaggerignore:"true"` // 所属机构登记编
  22. Sn string `json:"sn" gorm:"size:128;" vd:"len($)>0;msg:'sn不能为空'"` // 设备sn
  23. Type int `json:"type" gorm:"size:32;"` // 1-手持枪 2-龙门
  24. OptType string `json:"optType"` // 操作类型
  25. common.ControlBy `swaggerignore:"true"`
  26. common.DeptBy `swaggerignore:"true"`
  27. }
  28. func (s *DeviceInsertReq) Generate(model *model.Device) {
  29. if s.Id != 0 {
  30. model.Id = s.Id
  31. }
  32. model.ProvUserId = s.ProvUserId
  33. //model.UserId = s.UserId
  34. model.ProvCmpCode = s.ProvCmpCode
  35. model.Sn = s.Sn
  36. model.Type = s.Type
  37. model.OptType = s.OptType
  38. if s.ControlBy.UpdateBy != 0 {
  39. model.UpdateBy = s.UpdateBy
  40. }
  41. if s.ControlBy.CreateBy != 0 {
  42. model.CreateBy = s.CreateBy
  43. }
  44. if s.DeptBy.DeptId != 0 {
  45. model.DeptId = s.DeptId
  46. }
  47. }
  48. func (s *DeviceInsertReq) GetId() interface{} {
  49. return s.Id
  50. }
  51. type DeviceUpdateReq struct {
  52. Id int `json:"id" comment:"编码"` // 编码
  53. ProvUserId string `json:"provUserId"` // 省平台用户id
  54. UserId int `json:"userId" swaggerignore:"true"` // 客户id
  55. Sn string `json:"sn"` // 设备sn
  56. Type int `json:"type"` // 1-手持枪 2-龙门
  57. OptType string `json:"optType"` // 操作类型
  58. common.ControlBy `swaggerignore:"true"`
  59. }
  60. func (s *DeviceUpdateReq) Generate(model *model.Device) {
  61. if s.Id != 0 {
  62. model.Id = s.Id
  63. }
  64. model.ProvUserId = s.ProvUserId
  65. model.Sn = s.Sn
  66. model.Type = s.Type
  67. model.OptType = s.OptType
  68. if s.ControlBy.UpdateBy != 0 {
  69. model.UpdateBy = s.UpdateBy
  70. }
  71. if s.ControlBy.CreateBy != 0 {
  72. model.CreateBy = s.CreateBy
  73. }
  74. }
  75. func (s *DeviceUpdateReq) GetId() interface{} {
  76. return s.Id
  77. }
  78. type DeviceGetReq struct {
  79. Id int `uri:"id"`
  80. }
  81. func (s *DeviceGetReq) GetId() interface{} {
  82. return s.Id
  83. }
  84. type DeviceDeleteReq struct {
  85. Id int `json:"id"`
  86. common.ControlBy `swaggerignore:"true"`
  87. }
  88. func (s *DeviceDeleteReq) GetId() interface{} {
  89. return s.Id
  90. }