提交 afb01b02 编写于 作者: 7 710leo

fix: batch update alert rule

上级 d92ca5f2
......@@ -164,7 +164,7 @@ func alertRuleStatusPut(c *gin.Context) {
alertRuleWritePermCheck(arg, me)
}
renderMessage(c, models.AlertRuleUpdateStatus(f.Ids, f.Status))
renderMessage(c, models.AlertRuleUpdateStatus(f.Ids, f.Status, me.Username))
}
type alertRuleNotifyGroupsForm struct {
......@@ -189,7 +189,7 @@ func alertRuleNotifyGroupsPut(c *gin.Context) {
alertRuleWritePermCheck(arg, me)
}
renderMessage(c, models.AlertRuleUpdateNotifyGroups(f.Ids, f.NotifyGroups, f.NotifyUsers))
renderMessage(c, models.AlertRuleUpdateNotifyGroups(f.Ids, f.NotifyGroups, f.NotifyUsers, me.Username))
}
type alertRuleNotifyChannelsForm struct {
......@@ -211,7 +211,7 @@ func alertRuleNotifyChannelsPut(c *gin.Context) {
alertRuleWritePermCheck(arg, me)
}
renderMessage(c, models.AlertRuleUpdateNotifyChannels(f.Ids, f.NotifyChannels))
renderMessage(c, models.AlertRuleUpdateNotifyChannels(f.Ids, f.NotifyChannels, me.Username))
}
type alertRuleAppendTagsForm struct {
......@@ -233,7 +233,7 @@ func alertRuleAppendTagsPut(c *gin.Context) {
alertRuleWritePermCheck(arg, me)
}
renderMessage(c, models.AlertRuleUpdateAppendTags(f.Ids, f.AppendTags))
renderMessage(c, models.AlertRuleUpdateAppendTags(f.Ids, f.AppendTags, me.Username))
}
func alertRuleDel(c *gin.Context) {
......
......@@ -291,23 +291,23 @@ func (ar *AlertRule) Update(cols ...string) error {
return nil
}
func AlertRuleUpdateStatus(ids []int64, status int) error {
_, err := DB.Exec("UPDATE alert_rule SET status=? WHERE id in ("+str.IdsString(ids)+")", status)
func AlertRuleUpdateStatus(ids []int64, status int, username string) error {
_, err := DB.Exec("UPDATE alert_rule SET status=?, update_at=?, update_by=? WHERE id in ("+str.IdsString(ids)+")", status, time.Now().Unix(), username)
return err
}
func AlertRuleUpdateNotifyGroups(ids []int64, notifyGroups string, notifyUsers string) error {
_, err := DB.Exec("UPDATE alert_rule SET notify_groups = ? , notify_users = ? where id in ("+str.IdsString(ids)+")", notifyGroups, notifyUsers)
func AlertRuleUpdateNotifyGroups(ids []int64, notifyGroups, notifyUsers, username string) error {
_, err := DB.Exec("UPDATE alert_rule SET notify_groups = ? , notify_users = ?, update_at = ?, update_by = ? where id in ("+str.IdsString(ids)+")", notifyGroups, notifyUsers, time.Now().Unix(), username)
return err
}
func AlertRuleUpdateNotifyChannels(ids []int64, notifyChannels string) error {
_, err := DB.Exec("UPDATE alert_rule SET notify_channels = ? where id in ("+str.IdsString(ids)+")", notifyChannels)
func AlertRuleUpdateNotifyChannels(ids []int64, notifyChannels, username string) error {
_, err := DB.Exec("UPDATE alert_rule SET notify_channels = ?, update_at = ?, update_by = ? where id in ("+str.IdsString(ids)+")", notifyChannels, time.Now().Unix(), username)
return err
}
func AlertRuleUpdateAppendTags(ids []int64, appendTags string) error {
_, err := DB.Exec("UPDATE alert_rule SET append_tags = ? where id in ("+str.IdsString(ids)+")", appendTags)
func AlertRuleUpdateAppendTags(ids []int64, appendTags, username string) error {
_, err := DB.Exec("UPDATE alert_rule SET append_tags = ?, update_at = ?, update_by = ? where id in ("+str.IdsString(ids)+")", appendTags, time.Now().Unix(), username)
return err
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册