cygx_config.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "hongze/hz_crm_api/models/cygx"
  7. "hongze/hz_crm_api/services/alarm_msg"
  8. "hongze/hz_crm_api/utils"
  9. )
  10. type CygxUserLabelColorSetList struct {
  11. List []*CygxUserLabelColorSet
  12. }
  13. type CygxUserLabelColorSet struct {
  14. SourceType int `description:"类型"`
  15. BackgroundColor string `description:"背景色"`
  16. TextClolr string `description:"字体色"`
  17. }
  18. var RaiUserLabelStyleSet = make(map[int]*CygxUserLabelColorSet)
  19. // 获取用户标签展示样式 (全局)
  20. func init() {
  21. var err error
  22. defer func() {
  23. if err != nil {
  24. fmt.Println(err)
  25. go alarm_msg.SendAlarmMsg(fmt.Sprint("获取用户标签展示样式 失败err:", err.Error()), 2)
  26. }
  27. }()
  28. conf, e := cygx.GetCygxConfigDetailByCode("cygx_user_label_color_set")
  29. if e != nil && e.Error() != utils.ErrNoRow() {
  30. err = errors.New("GetCygxConfigDetailByCode, Err: " + e.Error())
  31. return
  32. }
  33. if conf.ConfigValue == "" {
  34. err = errors.New("ConfigValue, 配置项内容为空 ")
  35. return
  36. }
  37. list := new(CygxUserLabelColorSetList)
  38. if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
  39. err = errors.New("配置值解析失败, Err: " + e.Error())
  40. return
  41. }
  42. for _, v := range list.List {
  43. RaiUserLabelStyleSet[v.SourceType] = v
  44. }
  45. return
  46. }