123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package common
- import (
- "app.yhyue.com/moapp/MessageCenter/entity"
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
- "app.yhyue.com/moapp/jybase/common"
- "fmt"
- "strings"
- )
- // InitClassSearchMap 初始化需要展示细化分类的消息分类信息
- func InitClassSearchMap() {
- entity.ClassSearchMap = map[int64]map[int64]entity.MsgClass{}
- // 初始化需要展示消息细化分类的groupid 和对应的class信息
- if config.ConfigJson.ClassSearchList != nil && len(config.ConfigJson.ClassSearchList) > 0 {
- groupIDs := config.ConfigJson.ClassSearchList
- qArr := []string{}
- for i := 0; i < len(groupIDs); i++ {
- qArr = append(qArr, fmt.Sprintf("%d", groupIDs[i]))
- }
- // 查库
- q := "SELECT * FROM message_class where group_id in (" + strings.Join(qArr, ",") + ");"
- rs := entity.Mysql.SelectBySql(q)
- if rs != nil && len(*rs) > 0 {
- for i := 0; i < len(*rs); i++ {
- groupID := common.Int64All((*rs)[i]["group_id"])
- msgName := common.ObjToString((*rs)[i]["msg_name"])
- msgType := common.Int64All((*rs)[i]["msg_type"])
- img := common.ObjToString((*rs)[i]["img"])
- // 处理成map
- if _, ok := entity.ClassSearchMap[groupID]; !ok {
- entity.ClassSearchMap[groupID] = map[int64]entity.MsgClass{}
- }
- entity.ClassSearchMap[groupID][msgType] = entity.MsgClass{
- Name: msgName,
- Img: img,
- }
- }
- }
- }
- }
- //func () {
- //
- //}
|