messageClass.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package common
  2. import (
  3. "app.yhyue.com/moapp/MessageCenter/entity"
  4. "app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
  5. "app.yhyue.com/moapp/jybase/common"
  6. "fmt"
  7. "strings"
  8. )
  9. // InitClassSearchMap 初始化需要展示细化分类的消息分类信息
  10. func InitClassSearchMap() {
  11. entity.ClassSearchMap = map[int64]map[int64]entity.MsgClass{}
  12. // 初始化需要展示消息细化分类的groupid 和对应的class信息
  13. if config.ConfigJson.ClassSearchList != nil && len(config.ConfigJson.ClassSearchList) > 0 {
  14. groupIDs := config.ConfigJson.ClassSearchList
  15. qArr := []string{}
  16. for i := 0; i < len(groupIDs); i++ {
  17. qArr = append(qArr, fmt.Sprintf("%d", groupIDs[i]))
  18. }
  19. // 查库
  20. q := "SELECT * FROM message_class where group_id in (" + strings.Join(qArr, ",") + ");"
  21. rs := entity.Mysql.SelectBySql(q)
  22. if rs != nil && len(*rs) > 0 {
  23. for i := 0; i < len(*rs); i++ {
  24. groupID := common.Int64All((*rs)[i]["group_id"])
  25. msgName := common.ObjToString((*rs)[i]["msg_name"])
  26. msgType := common.Int64All((*rs)[i]["msg_type"])
  27. img := common.ObjToString((*rs)[i]["img"])
  28. // 处理成map
  29. if _, ok := entity.ClassSearchMap[groupID]; !ok {
  30. entity.ClassSearchMap[groupID] = map[int64]entity.MsgClass{}
  31. }
  32. entity.ClassSearchMap[groupID][msgType] = entity.MsgClass{
  33. Name: msgName,
  34. Img: img,
  35. }
  36. }
  37. }
  38. }
  39. }
  40. //func () {
  41. //
  42. //}