device.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. package dto
  2. import (
  3. "IotAdmin/app/iot/models"
  4. "IotAdmin/common/dto"
  5. comModels "IotAdmin/common/models"
  6. "time"
  7. )
  8. type IotDeviceGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. BeginTime string `form:"beginTime" search:"type:gte;column:created_at;table:iot_device" comment:"创建时间"`
  11. EndTime string `form:"endTime" search:"type:lte;column:created_at;table:iot_device" comment:"创建时间"`
  12. IotDeviceOrder
  13. }
  14. type IotDeviceOrder struct {
  15. Sn string `form:"snOrder" search:"type:order;column:sn;table:iot_device"`
  16. Name string `form:"nameOrder" search:"type:order;column:name;table:iot_device"`
  17. Type string `form:"typeOrder" search:"type:order;column:type;table:iot_device"`
  18. Mode string `form:"modeOrder" search:"type:order;column:mode;table:iot_device"`
  19. }
  20. func (m *IotDeviceGetPageReq) GetNeedSearch() interface{} {
  21. return *m
  22. }
  23. // IotDeviceInsertReq 添加设备请求参数
  24. type IotDeviceInsertReq struct {
  25. Id int `json:"-" comment:"ID"` // ID
  26. GroupId string `json:"groupId" comment:"设备分组"`
  27. Sn string `json:"sn" comment:"设备编码"`
  28. Name string `json:"name" comment:"设备名称"`
  29. Type string `json:"type" comment:"设备类型"`
  30. Mode string `json:"mode" comment:"设备模式"`
  31. Cycle string `json:"cycle" comment:"上报周期"`
  32. Description string `json:"description" comment:"设备描述"`
  33. Protocol string `json:"protocol" comment:"表计协议"`
  34. Address string `json:"address" comment:"表计地址"`
  35. LvRef string `json:"lvRef" comment:"表计线基准电压"`
  36. PvRef string `json:"pvRef" comment:"表计相基准电压"`
  37. comModels.ControlBy
  38. }
  39. func (s *IotDeviceInsertReq) Generate(model *models.IotDevice) {
  40. if s.Id == 0 {
  41. model.Model = comModels.Model{Id: s.Id}
  42. }
  43. model.GroupId = s.GroupId
  44. model.Sn = s.Sn
  45. model.Name = s.Name
  46. model.Type = s.Type
  47. model.Mode = s.Mode
  48. model.Cycle = s.Cycle
  49. model.Description = s.Description
  50. model.Protocol = s.Protocol
  51. model.Address = s.Address
  52. model.LvRef = s.LvRef
  53. model.PvRef = s.PvRef
  54. model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
  55. }
  56. func (s *IotDeviceInsertReq) GetId() interface{} {
  57. return s.Id
  58. }
  59. // IotDeviceUpdateReq 修改设备请求参数
  60. type IotDeviceUpdateReq struct {
  61. Id int `uri:"id" comment:"ID"` // ID
  62. GroupId string `json:"groupId" comment:"设备分组"`
  63. Sn string `json:"sn" comment:"设备编码"`
  64. Name string `json:"name" comment:"设备名称"`
  65. Type string `json:"type" comment:"设备类型"`
  66. Mode string `json:"mode" comment:"设备模式"`
  67. Cycle string `json:"cycle" comment:"上报周期"`
  68. Description string `json:"description" comment:"设备描述"`
  69. Protocol string `json:"protocol" comment:"表计协议"`
  70. Address string `json:"address" comment:"表计地址"`
  71. LvRef string `json:"lvRef" comment:"表计线基准电压"`
  72. PvRef string `json:"pvRef" comment:"表计相基准电压"`
  73. comModels.ControlBy
  74. }
  75. func (s *IotDeviceUpdateReq) Generate(model *models.IotDevice) {
  76. if s.Id == 0 {
  77. model.Model = comModels.Model{Id: s.Id}
  78. }
  79. model.GroupId = s.GroupId
  80. model.Sn = s.Sn
  81. model.Name = s.Name
  82. model.Type = s.Type
  83. model.Mode = s.Mode
  84. model.Cycle = s.Cycle
  85. model.Description = s.Description
  86. model.Protocol = s.Protocol
  87. model.Address = s.Address
  88. model.LvRef = s.LvRef
  89. model.PvRef = s.PvRef
  90. model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
  91. }
  92. func (s *IotDeviceUpdateReq) GetId() interface{} {
  93. return s.Id
  94. }
  95. // IotDeviceGetReq 获取设备请求参数
  96. type IotDeviceGetReq struct {
  97. Id int `uri:"id"`
  98. }
  99. func (s *IotDeviceGetReq) GetId() interface{} {
  100. return s.Id
  101. }
  102. // IotDeviceDeleteReq 删除设备请求参数
  103. type IotDeviceDeleteReq struct {
  104. Ids []int `json:"ids"`
  105. }
  106. type Dsn struct {
  107. Host string `json:"host"`
  108. Protocol string `json:"protocol"`
  109. ST string `json:"st"`
  110. MN string `json:"mn"`
  111. User string `json:"user"`
  112. Pwd string `json:"pwd"`
  113. }
  114. func (s *IotDeviceDeleteReq) GetId() interface{} {
  115. return s.Ids
  116. }
  117. // IotDeviceResp 获取设备响应参数
  118. type IotDeviceResp struct {
  119. Id int `uri:"id" comment:"ID"` // ID
  120. GroupId string `json:"groupId" comment:"设备分组"`
  121. Sn string `json:"sn" comment:"设备编码"`
  122. Name string `json:"name" comment:"设备名称"`
  123. Type string `json:"type" comment:"设备类型"`
  124. Mode string `json:"mode" comment:"设备模式"`
  125. Cycle string `json:"cycle" comment:"上报周期"`
  126. Description string `json:"description" comment:"设备描述"`
  127. Protocol string `json:"protocol" comment:"表计协议"`
  128. Address string `json:"address" comment:"表计地址"`
  129. LvRef string `json:"lvRef" comment:"表计线基准电压"`
  130. PvRef string `json:"pvRef" comment:"表计相基准电压"`
  131. CreateBy int `json:"createBy" comment:"创建者"`
  132. CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  133. }
  134. func (s *IotDeviceResp) Generate(model *models.IotDevice) {
  135. s.Id = model.Id
  136. s.GroupId = model.GroupId
  137. s.Sn = model.Sn
  138. s.Name = model.Name
  139. s.Type = model.Type
  140. s.Mode = model.Mode
  141. s.Cycle = model.Cycle
  142. s.Description = model.Description
  143. s.Protocol = model.Protocol
  144. s.Address = model.Address
  145. s.LvRef = model.LvRef
  146. s.PvRef = model.PvRef
  147. s.CreateBy = model.CreateBy
  148. s.CreatedAt = model.CreatedAt
  149. }