AlertCurEventGetByIds

This commit is contained in:
Ulric Qin 2022-03-22 15:24:25 +08:00
parent 9ccdd6c3e7
commit 8bdd35975e
3 changed files with 16 additions and 1 deletions

View File

@ -350,6 +350,17 @@ func AlertCurEventGetAll(cluster string) ([]*AlertCurEvent, error) {
return lst, err return lst, err
} }
func AlertCurEventGetByIds(ids []int64) ([]*AlertCurEvent, error) {
var lst []*AlertCurEvent
if len(ids) == 0 {
return lst, nil
}
err := DB().Where("id in ?", ids).Order("id desc").Find(&lst).Error
return lst, err
}
func AlertCurEventGetByRule(ruleId int64) ([]*AlertCurEvent, error) { func AlertCurEventGetByRule(ruleId int64) ([]*AlertCurEvent, error) {
var lst []*AlertCurEvent var lst []*AlertCurEvent
err := DB().Where("rule_id=?", ruleId).Find(&lst).Error err := DB().Where("rule_id=?", ruleId).Find(&lst).Error

View File

@ -221,7 +221,7 @@ func configRoute(r *gin.Engine, version string) {
// card logic // card logic
pages.GET("/alert-cur-events/list", jwtAuth(), alertCurEventsList) pages.GET("/alert-cur-events/list", jwtAuth(), alertCurEventsList)
pages.GET("/alert-cur-events/card", jwtAuth(), alertCurEventsCard) pages.GET("/alert-cur-events/card", jwtAuth(), alertCurEventsCard)
pages.GET("/alert-cur-events/card/details", jwtAuth(), alertCurEventsCardDetails) pages.POST("/alert-cur-events/card/details", jwtAuth(), alertCurEventsCardDetails)
pages.GET("/alert-his-events/list", jwtAuth(), alertHisEventsList) pages.GET("/alert-his-events/list", jwtAuth(), alertHisEventsList)
pages.DELETE("/alert-cur-events", jwtAuth(), user(), perm("/alert-cur-events/del"), alertCurEventDel) pages.DELETE("/alert-cur-events", jwtAuth(), user(), perm("/alert-cur-events/del"), alertCurEventDel)

View File

@ -87,7 +87,11 @@ type AlertCard struct {
} }
func alertCurEventsCardDetails(c *gin.Context) { func alertCurEventsCardDetails(c *gin.Context) {
var f idsForm
ginx.BindJSON(c, &f)
lst, err := models.AlertCurEventGetByIds(f.Ids)
ginx.NewRender(c).Data(lst, err)
} }
// 列表方式,拉取活跃告警 // 列表方式,拉取活跃告警