| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- package dto
- import (
- "IotAdmin/app/iot/models"
- "IotAdmin/common/dto"
- comModels "IotAdmin/common/models"
- "time"
- )
- type IotDeviceGetPageReq struct {
- dto.Pagination `search:"-"`
- BeginTime string `form:"beginTime" search:"type:gte;column:created_at;table:iot_device" comment:"创建时间"`
- EndTime string `form:"endTime" search:"type:lte;column:created_at;table:iot_device" comment:"创建时间"`
- IotDeviceOrder
- }
- type IotDeviceOrder struct {
- Sn string `form:"snOrder" search:"type:order;column:sn;table:iot_device"`
- Name string `form:"nameOrder" search:"type:order;column:name;table:iot_device"`
- Type string `form:"typeOrder" search:"type:order;column:type;table:iot_device"`
- Mode string `form:"modeOrder" search:"type:order;column:mode;table:iot_device"`
- }
- func (m *IotDeviceGetPageReq) GetNeedSearch() interface{} {
- return *m
- }
- // IotDeviceInsertReq 添加设备请求参数
- type IotDeviceInsertReq struct {
- Id int `json:"-" comment:"ID"` // ID
- GroupId string `json:"groupId" comment:"设备分组"`
- Sn string `json:"sn" comment:"设备编码"`
- Name string `json:"name" comment:"设备名称"`
- Type string `json:"type" comment:"设备类型"`
- Mode string `json:"mode" comment:"设备模式"`
- Cycle string `json:"cycle" comment:"上报周期"`
- Description string `json:"description" comment:"设备描述"`
- Protocol string `json:"protocol" comment:"表计协议"`
- Address string `json:"address" comment:"表计地址"`
- LvRef string `json:"lvRef" comment:"表计线基准电压"`
- PvRef string `json:"pvRef" comment:"表计相基准电压"`
- comModels.ControlBy
- }
- func (s *IotDeviceInsertReq) Generate(model *models.IotDevice) {
- if s.Id == 0 {
- model.Model = comModels.Model{Id: s.Id}
- }
- model.GroupId = s.GroupId
- model.Sn = s.Sn
- model.Name = s.Name
- model.Type = s.Type
- model.Mode = s.Mode
- model.Cycle = s.Cycle
- model.Description = s.Description
- model.Protocol = s.Protocol
- model.Address = s.Address
- model.LvRef = s.LvRef
- model.PvRef = s.PvRef
- model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
- }
- func (s *IotDeviceInsertReq) GetId() interface{} {
- return s.Id
- }
- // IotDeviceUpdateReq 修改设备请求参数
- type IotDeviceUpdateReq struct {
- Id int `uri:"id" comment:"ID"` // ID
- GroupId string `json:"groupId" comment:"设备分组"`
- Sn string `json:"sn" comment:"设备编码"`
- Name string `json:"name" comment:"设备名称"`
- Type string `json:"type" comment:"设备类型"`
- Mode string `json:"mode" comment:"设备模式"`
- Cycle string `json:"cycle" comment:"上报周期"`
- Description string `json:"description" comment:"设备描述"`
- Protocol string `json:"protocol" comment:"表计协议"`
- Address string `json:"address" comment:"表计地址"`
- LvRef string `json:"lvRef" comment:"表计线基准电压"`
- PvRef string `json:"pvRef" comment:"表计相基准电压"`
- comModels.ControlBy
- }
- func (s *IotDeviceUpdateReq) Generate(model *models.IotDevice) {
- if s.Id == 0 {
- model.Model = comModels.Model{Id: s.Id}
- }
- model.GroupId = s.GroupId
- model.Sn = s.Sn
- model.Name = s.Name
- model.Type = s.Type
- model.Mode = s.Mode
- model.Cycle = s.Cycle
- model.Description = s.Description
- model.Protocol = s.Protocol
- model.Address = s.Address
- model.LvRef = s.LvRef
- model.PvRef = s.PvRef
- model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
- }
- func (s *IotDeviceUpdateReq) GetId() interface{} {
- return s.Id
- }
- // IotDeviceGetReq 获取设备请求参数
- type IotDeviceGetReq struct {
- Id int `uri:"id"`
- }
- func (s *IotDeviceGetReq) GetId() interface{} {
- return s.Id
- }
- // IotDeviceDeleteReq 删除设备请求参数
- type IotDeviceDeleteReq struct {
- Ids []int `json:"ids"`
- }
- type Dsn struct {
- Host string `json:"host"`
- Protocol string `json:"protocol"`
- ST string `json:"st"`
- MN string `json:"mn"`
- User string `json:"user"`
- Pwd string `json:"pwd"`
- }
- func (s *IotDeviceDeleteReq) GetId() interface{} {
- return s.Ids
- }
- // IotDeviceResp 获取设备响应参数
- type IotDeviceResp struct {
- Id int `uri:"id" comment:"ID"` // ID
- GroupId string `json:"groupId" comment:"设备分组"`
- Sn string `json:"sn" comment:"设备编码"`
- Name string `json:"name" comment:"设备名称"`
- Type string `json:"type" comment:"设备类型"`
- Mode string `json:"mode" comment:"设备模式"`
- Cycle string `json:"cycle" comment:"上报周期"`
- Description string `json:"description" comment:"设备描述"`
- Protocol string `json:"protocol" comment:"表计协议"`
- Address string `json:"address" comment:"表计地址"`
- LvRef string `json:"lvRef" comment:"表计线基准电压"`
- PvRef string `json:"pvRef" comment:"表计相基准电压"`
- CreateBy int `json:"createBy" comment:"创建者"`
- CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
- }
- func (s *IotDeviceResp) Generate(model *models.IotDevice) {
- s.Id = model.Id
- s.GroupId = model.GroupId
- s.Sn = model.Sn
- s.Name = model.Name
- s.Type = model.Type
- s.Mode = model.Mode
- s.Cycle = model.Cycle
- s.Description = model.Description
- s.Protocol = model.Protocol
- s.Address = model.Address
- s.LvRef = model.LvRef
- s.PvRef = model.PvRef
- s.CreateBy = model.CreateBy
- s.CreatedAt = model.CreatedAt
- }
|