zhangchuanxing 17 timmar sedan
förälder
incheckning
9d4e15be7f

+ 9 - 0
controllers/cygx/user_rai_label.go

@@ -353,8 +353,17 @@ func (this *UserRaiLabelController) List() {
 		br.ErrMsg = "获取失败,Err:" + err.Error() + "userId:" + strconv.Itoa(userId)
 		return
 	}
+
 	if len(list) == 0 {
 		list = make([]*cygx.WxUserRaiLabelListResp, 0)
+	} else {
+		RaiUserLabelStyleSetConfig := cygxService.RaiUserLabelStyleSet
+		for _, v := range list {
+			if RaiUserLabelStyleSetConfig[v.SourceType] != nil {
+				v.BackgroundColor = RaiUserLabelStyleSetConfig[v.SourceType].BackgroundColor
+				v.TextClolr = RaiUserLabelStyleSetConfig[v.SourceType].TextClolr
+			}
+		}
 	}
 	resp.List = list
 	br.Ret = 200

+ 6 - 4
models/cygx/wx_user_rai_label.go

@@ -50,10 +50,12 @@ type WxUserRaiLabelList struct {
 }
 
 type WxUserRaiLabelListResp struct {
-	UserId     int    `description:"用户ID"`
-	RaiLabelId int    `description:"ID"`
-	Label      string `description:"标签内容"`
-	SourceType int    `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+	UserId          int    `description:"用户ID"`
+	RaiLabelId      int    `description:"ID"`
+	Label           string `description:"标签内容"`
+	BackgroundColor string `description:"背景颜色"`
+	TextClolr       string `description:"字体颜色"`
+	SourceType      int    `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
 }
 
 type WxUserRaiLabelAddReq struct {

+ 51 - 0
services/cygx/cygx_config.go

@@ -0,0 +1,51 @@
+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
+}

+ 5 - 0
services/cygx/user_rai_label.go

@@ -27,7 +27,12 @@ func GetUserLabelByUserIdArr(userIdArr []int) (mapRsp map[int][]*cygx.WxUserRaiL
 		return
 	}
 	mapRsp = make(map[int][]*cygx.WxUserRaiLabelListResp)
+	RaiUserLabelStyleSetConfig := RaiUserLabelStyleSet
 	for _, v := range labelList {
+		if RaiUserLabelStyleSet[v.SourceType] != nil {
+			v.BackgroundColor = RaiUserLabelStyleSetConfig[v.SourceType].BackgroundColor
+			v.TextClolr = RaiUserLabelStyleSetConfig[v.SourceType].TextClolr
+		}
 		mapRsp[v.UserId] = append(mapRsp[v.UserId], v)
 	}
 	return