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 }