瀏覽代碼

fix:消息数量减少增加对异常数据处理

fuwencai 2 年之前
父節點
當前提交
4278f1ba50
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      service/sendMsg.go

+ 3 - 0
service/sendMsg.go

@@ -150,6 +150,9 @@ func MsgCountAdd(userId, msgType string) bool {
 // MsgCountMinusOne 根据消息类型未读消息数量减1
 func MsgCountMinusOne(userId, msgType string) bool {
 	keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
+	if redis.GetInt(redisModule, keyString) <= 0 {
+		return redis.Put(redisModule, keyString, 0, -1)
+	}
 	in := redis.Decrby(redisModule, keyString, 1)
 	return in > 0
 }