Commit e6169241 authored by 李科's avatar 李科

fix: 预警列表

parent 498bfc45
...@@ -8,6 +8,17 @@ type DetailAlert struct { ...@@ -8,6 +8,17 @@ type DetailAlert struct {
Id int `json:"id" form:"id" binding:"required"` Id int `json:"id" form:"id" binding:"required"`
} }
type ListAlert struct {
Id int `json:"id" form:"id"`
Ids []int `json:"ids" form:"ids"` // 预警ids
RiskLevel int `json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"` // 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
Status int `json:"status" form:"status" binding:"omitempty,oneof=1 2 3"` // 状态,1:已恢复 2:未恢复 3:已关闭
Keyword string `json:"keyword" form:"keyword"` // 预警点/分类/指标
StartTime string `json:"start_time" form:"start_time" binding:"omitempty,datetime=2006-01-02 15:04:05"`
EndTime string `json:"end_time" form:"end_time" binding:"omitempty,datetime=2006-01-02 15:04:05"`
Pagination
}
type UpdateAlert struct { type UpdateAlert struct {
Id int `json:"id" form:"id" binding:"required"` Id int `json:"id" form:"id" binding:"required"`
//Ids []int `json:"ids" form:"ids" binding:"required_without=Id"` // 预警ids //Ids []int `json:"ids" form:"ids" binding:"required_without=Id"` // 预警ids
...@@ -33,17 +44,6 @@ type BatchCloseAlert struct { ...@@ -33,17 +44,6 @@ type BatchCloseAlert struct {
DeferPush int `json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"` // 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现 DeferPush int `json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"` // 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
} }
type ListAlert struct {
Id int `json:"id" form:"id"`
Ids []int `json:"ids" form:"ids" binding:"required_without=Id"` // 预警ids
RiskLevel int `json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"` // 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
Status int `json:"status" form:"status" binding:"omitempty,oneof=1 2 3"` // 状态,1:已恢复 2:未恢复 3:已关闭
Keyword string `json:"keyword" form:"keyword"` // 预警点/分类/指标
StartTime string `json:"start_time" form:"start_time" binding:"omitempty,datetime=2006-01-02 15:04:05"`
EndTime string `json:"end_time" form:"end_time" binding:"omitempty,datetime=2006-01-02 15:04:05"`
Pagination
}
type DisposeAlert struct { type DisposeAlert struct {
Id int `json:"id" form:"id" binding:"required"` Id int `json:"id" form:"id" binding:"required"`
Status int `json:"status" form:"status" binding:"oneof=1 2"` // 状态,1:已恢复 2:未恢复 3:已关闭 Status int `json:"status" form:"status" binding:"oneof=1 2"` // 状态,1:已恢复 2:未恢复 3:已关闭
......
...@@ -8,47 +8,46 @@ import ( ...@@ -8,47 +8,46 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
) )
func UpdateAlert(c *gin.Context) { func DetailAlert(c *gin.Context) {
var req request.UpdateAlert var req request.DetailAlert
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
svc := service.AlertSvc{User: header.GetUser(c)} svc := service.AlertSvc{User: header.GetUser(c)}
err := svc.Update(req) data, err := svc.GetDataById(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), nil) SendJsonResponse(c, resp.FAIL.WithError(err), nil)
return return
} }
SendJsonResponse(c, resp.OK, nil) SendJsonResponse(c, resp.OK, data)
} }
func BatchPushAlert(c *gin.Context) { func ListAlert(c *gin.Context) {
var req request.BatchPushAlert var req request.ListAlert
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
svc := service.AlertSvc{User: header.GetUser(c)} svc := service.AlertSvc{User: header.GetUser(c)}
err := svc.BatchPushAlert(req) data, err := svc.List(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), nil) SendJsonResponse(c, resp.FAIL.WithError(err), nil)
return return
} }
SendJsonResponse(c, resp.OK, nil) SendJsonResponse(c, resp.OK, data)
} }
func BatchCloseAlert(c *gin.Context) { func UpdateAlert(c *gin.Context) {
var req request.BatchCloseAlert var req request.UpdateAlert
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
svc := service.AlertSvc{User: header.GetUser(c)} svc := service.AlertSvc{User: header.GetUser(c)}
err := svc.BatchCloseAlert(req) err := svc.Update(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), nil) SendJsonResponse(c, resp.FAIL.WithError(err), nil)
return return
...@@ -56,35 +55,36 @@ func BatchCloseAlert(c *gin.Context) { ...@@ -56,35 +55,36 @@ func BatchCloseAlert(c *gin.Context) {
SendJsonResponse(c, resp.OK, nil) SendJsonResponse(c, resp.OK, nil)
} }
func DetailAlert(c *gin.Context) { func BatchPushAlert(c *gin.Context) {
var req request.DetailAlert var req request.BatchPushAlert
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
svc := service.AlertSvc{User: header.GetUser(c)} svc := service.AlertSvc{User: header.GetUser(c)}
data, err := svc.GetDataById(req) err := svc.BatchPushAlert(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), nil) SendJsonResponse(c, resp.FAIL.WithError(err), nil)
return return
} }
SendJsonResponse(c, resp.OK, data) SendJsonResponse(c, resp.OK, nil)
} }
func ListAlert(c *gin.Context) { func BatchCloseAlert(c *gin.Context) {
var req request.ListAlert var req request.BatchCloseAlert
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
svc := service.AlertSvc{User: header.GetUser(c)} svc := service.AlertSvc{User: header.GetUser(c)}
data, err := svc.List(req) err := svc.BatchCloseAlert(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), nil) SendJsonResponse(c, resp.FAIL.WithError(err), nil)
return return
} }
SendJsonResponse(c, resp.OK, data) SendJsonResponse(c, resp.OK, nil)
} }
func DisposeAlert(c *gin.Context) { func DisposeAlert(c *gin.Context) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment