Browse Source

feature(mcs_api): 添加 channels/entity 接口

liuyaqi 3 years ago
parent
commit
b41c706419

+ 12 - 0
backend/src/dashoo.cn/mcs_api/business/device/deviceService.go

@@ -586,3 +586,15 @@ func (s *DeviceService) GetAllSerialsByOrgTopIdDitem(topids []string, item, uid
 	s.DBE.SQL(sql).Find(&ids)
 	return
 }
+
+func (s *DeviceService) GetChannelsBySerial(serial string) Channels {
+	var c Channels
+	s.DBE.SQL(`select * from Channels where Serial=`+serial).Get(&c)
+	return c
+}
+
+func (s *DeviceService) GetChannelsByEquipMentId(equipMentId string) Channels {
+	var c Channels
+	s.DBE.SQL(`select * from Channels where EquipMentId=`+equipMentId).Get(&c)
+	return c
+}

+ 26 - 0
backend/src/dashoo.cn/mcs_api/controllers/channels.go

@@ -141,6 +141,32 @@ func (this *ChannelsController) List() {
 	this.ServeJSON()
 }
 
+// @Title 设备列表
+// @Description 设备列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /entity [get]
+func (this *ChannelsController) Entity() {
+	equipMentId := this.GetString("equipMentId")
+	serial := this.GetString("serial")
+	if equipMentId == "" && serial == ""  {
+		return
+	}
+
+	svc := device.GetDeviceService(utils.DBE)
+	if equipMentId != "" {
+		c := svc.GetChannelsByEquipMentId(equipMentId)
+		this.Data["json"] = c
+		this.ServeJSON()
+		return
+	}
+	if serial != "" {
+		c := svc.GetChannelsBySerial(serial)
+		this.Data["json"] = c
+		this.ServeJSON()
+		return
+	}
+}
+
 // @Title 设备列表
 // @Description 设备列表
 // @Success 200 {object} business.device.DeviceChannels