fix alert rule delete by service
This commit is contained in:
parent
ab5e8c366e
commit
495632a064
|
@ -237,9 +237,13 @@ func (ar *AlertRule) DB2FE() {
|
|||
json.Unmarshal([]byte(ar.AlgoParams), &ar.AlgoParamsJson)
|
||||
}
|
||||
|
||||
func AlertRuleDels(ids []int64, busiGroupId int64) error {
|
||||
func AlertRuleDels(ids []int64, bgid ...int64) error {
|
||||
for i := 0; i < len(ids); i++ {
|
||||
ret := DB().Where("id = ? and group_id=?", ids[i], busiGroupId).Delete(&AlertRule{})
|
||||
session := DB().Where("id = ?", ids[i])
|
||||
if len(bgid) > 0 {
|
||||
session = session.Where("group_id = ?", bgid[0])
|
||||
}
|
||||
ret := session.Delete(&AlertRule{})
|
||||
if ret.Error != nil {
|
||||
return ret.Error
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ func configRoute(r *gin.Engine, version string) {
|
|||
|
||||
service.GET("/alert-rules", alertRuleGets)
|
||||
service.POST("/alert-rules", alertRuleAddByService)
|
||||
service.DELETE("/alert-rules", alertRuleDel)
|
||||
service.DELETE("/alert-rules", alertRuleDelByService)
|
||||
service.PUT("/alert-rule/:arid", alertRulePutByService)
|
||||
service.GET("/alert-rule/:arid", alertRuleGet)
|
||||
service.GET("/alert-rules-get-by-prod", alertRulesGetByProds)
|
||||
|
|
|
@ -129,6 +129,13 @@ func alertRuleDel(c *gin.Context) {
|
|||
ginx.NewRender(c).Message(models.AlertRuleDels(f.Ids, ginx.UrlParamInt64(c, "id")))
|
||||
}
|
||||
|
||||
func alertRuleDelByService(c *gin.Context) {
|
||||
var f idsForm
|
||||
ginx.BindJSON(c, &f)
|
||||
f.Verify()
|
||||
ginx.NewRender(c).Message(models.AlertRuleDels(f.Ids))
|
||||
}
|
||||
|
||||
func alertRulePutByFE(c *gin.Context) {
|
||||
var f models.AlertRule
|
||||
ginx.BindJSON(c, &f)
|
||||
|
|
Loading…
Reference in New Issue