mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
[优化] 将部分在services中抛出异常使用error返回
This commit is contained in:
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
// ==========================================================================
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"strings"
|
||||
@@ -15,7 +16,7 @@ type DeviceAlarmApi struct {
|
||||
}
|
||||
|
||||
func (p *DeviceAlarmApi) GetDeviceAlarmPanel(rc *restfulx.ReqCtx) {
|
||||
panel := p.DeviceAlarmApp.FindAlarmPanel()
|
||||
panel, _ := p.DeviceAlarmApp.FindAlarmPanel()
|
||||
rc.ResData = panel
|
||||
}
|
||||
|
||||
@@ -34,8 +35,8 @@ func (p *DeviceAlarmApi) GetDeviceAlarmList(rc *restfulx.ReqCtx) {
|
||||
data.RoleId = rc.LoginAccount.RoleId
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
|
||||
list, total := p.DeviceAlarmApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.DeviceAlarmApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "设备查询失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -48,12 +49,14 @@ func (p *DeviceAlarmApi) GetDeviceAlarmList(rc *restfulx.ReqCtx) {
|
||||
func (p *DeviceAlarmApi) UpdateDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
var data entity.DeviceAlarm
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
p.DeviceAlarmApp.Update(data)
|
||||
err := p.DeviceAlarmApp.Update(data)
|
||||
biz.ErrIsNil(err, "修改告警失败")
|
||||
}
|
||||
|
||||
// DeleteDeviceAlarm 删除告警
|
||||
func (p *DeviceAlarmApi) DeleteDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
p.DeviceAlarmApp.Delete(ids)
|
||||
err := p.DeviceAlarmApp.Delete(ids)
|
||||
biz.ErrIsNil(err, "删除告警失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user