messageClass.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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][]entity.MsgClass{}
  12. entity.ClassMap = map[int64]entity.MsgClass{}
  13. // 初始化需要展示消息细化分类的groupid 和对应的class信息
  14. if config.ConfigJson.ClassSearchList != nil && len(config.ConfigJson.ClassSearchList) > 0 {
  15. groupIDs := config.ConfigJson.ClassSearchList
  16. qArr := []string{}
  17. for i := 0; i < len(groupIDs); i++ {
  18. qArr = append(qArr, fmt.Sprintf("%d", groupIDs[i]))
  19. }
  20. // 查库
  21. q := "SELECT * FROM message_class where group_id in (" + strings.Join(qArr, ",") + ") order by msg_type;"
  22. rs := entity.Mysql.SelectBySql(q)
  23. if rs != nil && len(*rs) > 0 {
  24. for i := 0; i < len(*rs); i++ {
  25. groupID := common.Int64All((*rs)[i]["group_id"])
  26. msgName := common.ObjToString((*rs)[i]["msg_name"])
  27. msgType := common.Int64All((*rs)[i]["msg_type"])
  28. img := common.ObjToString((*rs)[i]["img"])
  29. // 处理成map
  30. if _, ok := entity.ClassSearchMap[groupID]; !ok {
  31. entity.ClassSearchMap[groupID] = []entity.MsgClass{}
  32. }
  33. tmp := entity.MsgClass{
  34. MsgType: msgType,
  35. Name: msgName,
  36. Img: img,
  37. }
  38. entity.ClassSearchMap[groupID] = append(entity.ClassSearchMap[groupID],tmp)
  39. entity.ClassMap[msgType] = tmp
  40. }
  41. }
  42. }
  43. }
  44. //func () {
  45. //
  46. //}