mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-27 07:59:36 +08:00
iot init
This commit is contained in:
49
apps/device/api/device_alarm.go
Normal file
49
apps/device/api/device_alarm.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package api
|
||||
|
||||
// ==========================================================================
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"strings"
|
||||
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
)
|
||||
|
||||
type DeviceAlarmApi struct {
|
||||
DeviceAlarmApp services.DeviceAlarmModel
|
||||
}
|
||||
|
||||
// GetDeviceAlarmList 告警列表数据
|
||||
func (p *DeviceAlarmApi) GetDeviceAlarmList(rc *restfulx.ReqCtx) {
|
||||
data := entity.DeviceAlarm{}
|
||||
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
|
||||
data.DeviceId = restfulx.QueryParam(rc, "deviceId")
|
||||
data.Type = restfulx.QueryParam(rc, "type")
|
||||
data.Level = restfulx.QueryParam(rc, "level")
|
||||
data.State = restfulx.QueryParam(rc, "state")
|
||||
|
||||
list, total := p.DeviceAlarmApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
PageSize: int64(pageNum),
|
||||
Data: list,
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateDeviceAlarm 修改告警
|
||||
func (p *DeviceAlarmApi) UpdateDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
var data entity.DeviceAlarm
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
p.DeviceAlarmApp.Update(data)
|
||||
}
|
||||
|
||||
// DeleteDeviceAlarm 删除告警
|
||||
func (p *DeviceAlarmApi) DeleteDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
p.DeviceAlarmApp.Delete(ids)
|
||||
}
|
||||
Reference in New Issue
Block a user