123456789101112131415161718192021222324252627282930313233 |
- package common
- import (
- "app.yhyue.com/moapp/MessageCenter/entity"
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
- "app.yhyue.com/moapp/jybase/common"
- "fmt"
- "github.com/robfig/cron/v3"
- )
- var GlobMsgMap map[int]map[string]interface{}
- func LoadTask() {
- // 每隔10分钟执行一次
- LoadMsgOnTime()
- c := cron.New(cron.WithSeconds())
- c.AddFunc(config.ConfigJson.GlobMsgLoadTime, LoadMsgOnTime)
- go c.Start()
- defer c.Stop()
- }
- func LoadMsgOnTime() {
- fmt.Println("开始执行")
- msgMap := make(map[int]map[string]interface{})
- m := entity.Mysql.SelectBySql("SELECT id,msg_type,title,content,send_time,menu_name,link,group_id,sign FROM message_send_log WHERE send_status = 4 AND isdel = 1 ORDER BY send_time DESC limit 2000")
- if m != nil && len(*m) > 0 {
- for _, val := range *m {
- msgMap[common.IntAll(val["id"])] = val
- }
- GlobMsgMap = msgMap
- }
- fmt.Println("GlobMsgMap len", len(GlobMsgMap))
- }
|