Merge branch 'main' of github.com:ccfos/nightingale

This commit is contained in:
ning 2022-06-02 11:07:40 +08:00
commit 0e5aea40e8
4 changed files with 15 additions and 3 deletions

View File

@ -9,6 +9,7 @@ CREATE TABLE users (
portrait varchar(255) not null default '' ,
roles varchar(255) not null ,
contacts varchar(1024) ,
maintainer smallint not null default 0,
create_at bigint not null default 0,
create_by varchar(64) not null default '',
update_at bigint not null default 0,

View File

@ -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
}

View File

@ -277,7 +277,7 @@ func configRoute(r *gin.Engine, version string) {
service.PUT("/targets/note", targetUpdateNoteByService)
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", alertRulesGetByService)

View File

@ -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)