group.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. }
  17. func (m *IotGroupGetPageReq) GetNeedSearch() interface{} {
  18. return *m
  19. }
  20. // IotGroupInsertReq 添加分组请求参数
  21. type IotGroupInsertReq struct {
  22. Id int `json:"-" comment:"ID"` // ID
  23. ParentId string `json:"parentId" comment:"父ID"`
  24. Name string `json:"name" comment:"分组名称"`
  25. Description string `json:"description" comment:"分组描述"`
  26. comModels.ControlBy
  27. }
  28. func (s *IotGroupInsertReq) Generate(model *models.IotGroup) {
  29. if s.Id == 0 {
  30. model.Model = comModels.Model{ Id: s.Id }
  31. }
  32. model.ParentId = s.ParentId
  33. model.Name = s.Name
  34. model.Description = s.Description
  35. model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
  36. }
  37. func (s *IotGroupInsertReq) GetId() interface{} {
  38. return s.Id
  39. }
  40. // IotGroupUpdateReq 修改分组请求参数
  41. type IotGroupUpdateReq struct {
  42. Id int `uri:"id" comment:"ID"` // ID
  43. ParentId string `json:"parentId" comment:"父ID"`
  44. Name string `json:"name" comment:"分组名称"`
  45. Description string `json:"description" comment:"分组描述"`
  46. comModels.ControlBy
  47. }
  48. func (s *IotGroupUpdateReq) Generate(model *models.IotGroup) {
  49. if s.Id == 0 {
  50. model.Model = comModels.Model{ Id: s.Id }
  51. }
  52. model.ParentId = s.ParentId
  53. model.Name = s.Name
  54. model.Description = s.Description
  55. model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
  56. }
  57. func (s *IotGroupUpdateReq) GetId() interface{} {
  58. return s.Id
  59. }
  60. // IotGroupGetReq 获取分组请求参数
  61. type IotGroupGetReq struct {
  62. Id int `uri:"id"`
  63. }
  64. func (s *IotGroupGetReq) GetId() interface{} {
  65. return s.Id
  66. }
  67. // IotGroupDeleteReq 删除分组请求参数
  68. type IotGroupDeleteReq struct {
  69. Ids []int `json:"ids"`
  70. }
  71. func (s *IotGroupDeleteReq) GetId() interface{} {
  72. return s.Ids
  73. }
  74. // IotGroupResp 获取分组响应参数
  75. type IotGroupResp struct {
  76. Id int `uri:"id" comment:"ID"` // ID
  77. ParentId string `json:"parentId" comment:"父ID"`
  78. Name string `json:"name" comment:"分组名称"`
  79. Description string `json:"description" comment:"分组描述"`
  80. CreateBy int `json:"createBy" comment:"创建者"`
  81. CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  82. }
  83. func (s *IotGroupResp) Generate(model *models.IotGroup) {
  84. s.Id = model.Id
  85. s.ParentId = model.ParentId
  86. s.Name = model.Name
  87. s.Description = model.Description
  88. s.CreateBy = model.CreateBy
  89. s.CreatedAt = model.CreatedAt
  90. }