You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"laic-backend/common"
|
|
"laic-backend/service"
|
|
"laic-backend/vo"
|
|
)
|
|
|
|
// GetAlarmPage 告警分页列表
|
|
func GetAlarmPage(c *gin.Context) {
|
|
var req vo.AlarmPageReq
|
|
_ = c.ShouldBindQuery(&req)
|
|
if req.PageNum <= 0 {
|
|
req.PageNum = 1
|
|
}
|
|
if req.PageSize <= 0 {
|
|
req.PageSize = 10
|
|
}
|
|
page, busiErr := service.DefaultAlarmService.GetPage(common.GetUserId(c), common.IsAdmin(c), &req)
|
|
if busiErr != nil {
|
|
common.FailWithBusiError(c, busiErr)
|
|
return
|
|
}
|
|
common.OKWithData(c, page)
|
|
}
|
|
|
|
// AcknowledgeAlarm 确认告警
|
|
func AcknowledgeAlarm(c *gin.Context) {
|
|
id, busiErr := parseID(c)
|
|
if busiErr != nil {
|
|
common.FailWithBusiError(c, busiErr)
|
|
return
|
|
}
|
|
if busiErr := service.DefaultAlarmService.Acknowledge(common.GetUserId(c), common.IsAdmin(c), id); busiErr != nil {
|
|
common.FailWithBusiError(c, busiErr)
|
|
return
|
|
}
|
|
common.OK(c)
|
|
}
|
|
|
|
// ResolveAlarm 关闭告警
|
|
func ResolveAlarm(c *gin.Context) {
|
|
id, busiErr := parseID(c)
|
|
if busiErr != nil {
|
|
common.FailWithBusiError(c, busiErr)
|
|
return
|
|
}
|
|
if busiErr := service.DefaultAlarmService.Resolve(common.GetUserId(c), common.IsAdmin(c), id); busiErr != nil {
|
|
common.FailWithBusiError(c, busiErr)
|
|
return
|
|
}
|
|
common.OK(c)
|
|
}
|
|
|