group.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package dto
  2. import (
  3. "IotAdmin/app/iot/models"
  4. "IotAdmin/common/dto"
  5. comModels "IotAdmin/common/models"
  6. "time"
  7. )
  8. type IotGroupGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. BeginTime string `form:"beginTime" search:"type:gte;column:created_at;table:iot_group" comment:"创建时间"`
  11. EndTime string `form:"endTime" search:"type:lte;column:created_at;table:iot_group" comment:"创建时间"`
  12. IotGroupOrder
  13. }
  14. type IotGroupOrder struct {
  15. Name string `form:"nameOrder" search:"type:order;column:name;table:iot_group"`
  16. CreatedAtOrder string `search:"type:order;column:created_at;table:iot_group" form:"createdAtOrder"`
  17. }
  18. func (m *IotGroupGetPageReq) GetNeedSearch() interface{} {
  19. return *m
  20. }
  21. // IotGroupInsertReq 添加分组请求参数
  22. type IotGroupInsertReq struct {
  23. Id int `json:"-" comment:"Id"` // Id
  24. ParentId int `json:"parentId" comment:"父ID"`
  25. Name string `json:"name" comment:"分组名称"`
  26. Description string `json:"description" comment:"分组描述"`
  27. comModels.ControlBy
  28. }
  29. func (s *IotGroupInsertReq) Generate(model *models.IotGroup) {
  30. if s.Id == 0 {
  31. model.Model = comModels.Model{Id: s.Id}
  32. }
  33. model.ParentId = s.ParentId
  34. model.Name = s.Name
  35. model.Description = s.Description
  36. model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
  37. }
  38. func (s *IotGroupInsertReq) GetId() interface{} {
  39. return s.Id
  40. }
  41. // IotGroupUpdateReq 修改分组请求参数
  42. type IotGroupUpdateReq struct {
  43. Id int `uri:"id" comment:"Id"` // Id
  44. ParentId int `json:"parentId" comment:"父ID"`
  45. Name string `json:"name" comment:"分组名称"`
  46. Description string `json:"description" comment:"分组描述"`
  47. comModels.ControlBy
  48. }
  49. func (s *IotGroupUpdateReq) Generate(model *models.IotGroup) {
  50. if s.Id == 0 {
  51. model.Model = comModels.Model{Id: s.Id}
  52. }
  53. model.ParentId = s.ParentId
  54. model.Name = s.Name
  55. model.Description = s.Description
  56. model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
  57. }
  58. func (s *IotGroupUpdateReq) GetId() interface{} {
  59. return s.Id
  60. }
  61. // IotGroupGetReq 获取分组请求参数
  62. type IotGroupGetReq struct {
  63. Id int `uri:"id"`
  64. }
  65. func (s *IotGroupGetReq) GetId() interface{} {
  66. return s.Id
  67. }
  68. // IotGroupDeleteReq 删除分组请求参数
  69. type IotGroupDeleteReq struct {
  70. Ids []int `json:"ids"`
  71. }
  72. func (s *IotGroupDeleteReq) GetId() interface{} {
  73. return s.Ids
  74. }
  75. // IotGroupResp 获取分组响应参数
  76. type IotGroupResp struct {
  77. Id int `uri:"id" comment:"Id"` // Id
  78. ParentId int `json:"parentId" comment:"父ID"`
  79. Name string `json:"name" comment:"分组名称"`
  80. Description string `json:"description" comment:"分组描述"`
  81. CreateBy int `json:"createBy" comment:"创建者"`
  82. CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  83. }
  84. func (s *IotGroupResp) Generate(model *models.IotGroup) {
  85. s.Id = model.Id
  86. s.ParentId = model.ParentId
  87. s.Name = model.Name
  88. s.Description = model.Description
  89. s.CreateBy = model.CreateBy
  90. s.CreatedAt = model.CreatedAt
  91. }