package cygx import ( "encoding/json" "errors" "fmt" "hongze/hz_crm_api/models/cygx" "hongze/hz_crm_api/services/alarm_msg" "hongze/hz_crm_api/utils" ) type CygxUserLabelColorSetList struct { List []*CygxUserLabelColorSet } type CygxUserLabelColorSet struct { SourceType int `description:"类型"` BackgroundColor string `description:"背景色"` TextClolr string `description:"字体色"` } var RaiUserLabelStyleSet = make(map[int]*CygxUserLabelColorSet) // 获取用户标签展示样式 (全局) func init() { var err error defer func() { if err != nil { fmt.Println(err) go alarm_msg.SendAlarmMsg(fmt.Sprint("获取用户标签展示样式 失败err:", err.Error()), 2) } }() conf, e := cygx.GetCygxConfigDetailByCode("cygx_user_label_color_set") if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxConfigDetailByCode, Err: " + e.Error()) return } if conf.ConfigValue == "" { err = errors.New("ConfigValue, 配置项内容为空 ") return } list := new(CygxUserLabelColorSetList) if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil { err = errors.New("配置值解析失败, Err: " + e.Error()) return } for _, v := range list.List { RaiUserLabelStyleSet[v.SourceType] = v } return }