|
@@ -65,14 +65,18 @@ func (service *MessageService) CountUnread(userId string) int64 {
|
|
|
var count int64
|
|
|
var msgTypes []string
|
|
|
for _, v := range entity.MessageColumn {
|
|
|
- msgTypes = append(msgTypes, fmt.Sprintf(`"%s"`, qutil.InterfaceToStr(v["group_id"])))
|
|
|
+ if qutil.IntAll(v["group_id"]) > 0 && qutil.IntAll(v["group_id"]) < 999 {
|
|
|
+ msgTypes = append(msgTypes, fmt.Sprintf(`"%s"`, qutil.InterfaceToStr(v["group_id"])))
|
|
|
+ }
|
|
|
}
|
|
|
- query := entity.Mysql.SelectBySql(fmt.Sprintf("SELECT group_id,COUNT(CASE WHEN isRead=0 THEN 1 END) as count FROM message where receive_userid=? and isdel=1 GROUP BY group_id ORDER BY FIELD(`group_id`,%s)", strings.Join(msgTypes, ",")), userId)
|
|
|
- if query != nil && len(*query) > 0 {
|
|
|
- for _, v := range *query {
|
|
|
- count += qutil.Int64All(v["count"])
|
|
|
- key := fmt.Sprintf(MsgCountKey, userId, qutil.IntAll(v["group_id"]))
|
|
|
- redis.Put(redisModule, key, qutil.Int64All(v["count"]), -1)
|
|
|
+ if len(msgTypes) > 0 {
|
|
|
+ query := entity.Mysql.SelectBySql(fmt.Sprintf("SELECT group_id,COUNT(CASE WHEN isRead=0 THEN 1 END) as count FROM message where receive_userid=? and isdel=1 GROUP BY group_id ORDER BY FIELD(`group_id`,%s)", strings.Join(msgTypes, ",")), userId)
|
|
|
+ if query != nil && len(*query) > 0 {
|
|
|
+ for _, v := range *query {
|
|
|
+ count += qutil.Int64All(v["count"])
|
|
|
+ key := fmt.Sprintf(MsgCountKey, userId, qutil.IntAll(v["group_id"]))
|
|
|
+ redis.Put(redisModule, key, qutil.Int64All(v["count"]), -1)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|