stra add user group detail

This commit is contained in:
710leo 2021-03-19 11:12:32 +08:00
parent 184c39d311
commit 0a7c8988c6
1 changed files with 27 additions and 13 deletions

View File

@ -46,8 +46,10 @@ type Stra struct {
Tags []Tag `xorm:"-" json:"tags"` Tags []Tag `xorm:"-" json:"tags"`
EnableDaysOfWeek []int `xorm:"-" json:"enable_days_of_week"` EnableDaysOfWeek []int `xorm:"-" json:"enable_days_of_week"`
Converge []int `xorm:"-" json:"converge"` Converge []int `xorm:"-" json:"converge"`
NotifyGroup []int `xorm:"-" json:"notify_group"` NotifyGroup []int64 `xorm:"-" json:"notify_group"`
NotifyUser []int `xorm:"-" json:"notify_user"` NotifyGroupDetail []Team `xorm:"-" json:"notify_group_detail"`
NotifyUser []int64 `xorm:"-" json:"notify_user"`
NotifyUserDetail []User `xorm:"-" json:"notify_user_detail"`
LeafNids []int64 `xorm:"-" json:"leaf_nids"` //叶子节点id LeafNids []int64 `xorm:"-" json:"leaf_nids"` //叶子节点id
Endpoints []string `xorm:"-" json:"endpoints"` Endpoints []string `xorm:"-" json:"endpoints"`
AlertUpgrade AlertUpgrade `xorm:"-" json:"alert_upgrade"` AlertUpgrade AlertUpgrade `xorm:"-" json:"alert_upgrade"`
@ -504,12 +506,24 @@ func (s *Stra) Decode() error {
return err return err
} }
s.NotifyUserDetail, err = UserGets(s.NotifyUser, 10000, 0, "")
if err != nil {
logger.Errorf("decode strategy(%d) on NotifyUserDetail fail: %v", s.Id, err)
return err
}
err = json.Unmarshal([]byte(s.NotifyGroupStr), &s.NotifyGroup) err = json.Unmarshal([]byte(s.NotifyGroupStr), &s.NotifyGroup)
if err != nil { if err != nil {
logger.Errorf("decode strategy(%d) on NotifyGroup fail: %v", s.Id, err) logger.Errorf("decode strategy(%d) on NotifyGroup fail: %v", s.Id, err)
return err return err
} }
s.NotifyGroupDetail, err = TeamGetsInIds(s.NotifyGroup, "", 10000, 0)
if err != nil {
logger.Errorf("decode strategy(%d) on NotifyGroupDetail fail: %v", s.Id, err)
return err
}
if s.WorkGroupsStr != "" { if s.WorkGroupsStr != "" {
err = json.Unmarshal([]byte(s.WorkGroupsStr), &s.WorkGroups) err = json.Unmarshal([]byte(s.WorkGroupsStr), &s.WorkGroups)
if err != nil { if err != nil {