feat: 告警清除/确认/状态检查任务
This commit is contained in:
@@ -52,7 +52,7 @@ type AlarmController struct {
|
||||
// @Summary Alarm List
|
||||
// @Description Alarm List
|
||||
// @Router /neData/alarm/list [get]
|
||||
func (s *AlarmController) List(c *gin.Context) {
|
||||
func (s AlarmController) List(c *gin.Context) {
|
||||
var query model.AlarmQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -67,7 +67,7 @@ func (s *AlarmController) List(c *gin.Context) {
|
||||
// 告警删除
|
||||
//
|
||||
// DELETE /:id
|
||||
func (s *AlarmController) Remove(c *gin.Context) {
|
||||
func (s AlarmController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
@@ -91,3 +91,48 @@ func (s *AlarmController) Remove(c *gin.Context) {
|
||||
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
|
||||
c.JSON(200, resp.OkMsg(msg))
|
||||
}
|
||||
|
||||
// 告警清除
|
||||
//
|
||||
// PUT /clear
|
||||
func (s AlarmController) Clear(c *gin.Context) {
|
||||
var body struct {
|
||||
Ids []int64 `json:"ids" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
clearUser := reqctx.LoginUserToUserName(c)
|
||||
rows, err := s.alarmService.AlarmClearByIds(body.Ids, clearUser)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, resp.OkData(rows))
|
||||
}
|
||||
|
||||
// 告警确认
|
||||
//
|
||||
// PUT /ack
|
||||
func (s AlarmController) Ack(c *gin.Context) {
|
||||
var body struct {
|
||||
Ids []int64 `json:"ids" binding:"required"`
|
||||
AckState bool `json:"ackState" binding:"omitempty"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
ackUser := reqctx.LoginUserToUserName(c)
|
||||
rows, err := s.alarmService.AlarmAckByIds(body.Ids, ackUser, body.AckState)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, resp.OkData(rows))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user