|
@@ -18,7 +18,7 @@ import (
|
|
|
|
|
|
// 类型的顺序
|
|
|
const order = "1,4"
|
|
|
-const MsgCountKey = "count_%s_%s" //redis 消息未读数量 Count.用户id.消息类型=数量
|
|
|
+const MsgCountKey = "count_%s_%d" //redis 消息未读数量 Count.用户id.消息类型=数量
|
|
|
const redisModule = "msgCount"
|
|
|
|
|
|
func FindUserMsg(this message.FindUserMsgReq, isClean bool) message.FindUserMsgRes {
|
|
@@ -343,7 +343,7 @@ func ClassCountUnread(msgType int, userId string, appId string) (int64, string,
|
|
|
}
|
|
|
|
|
|
// MsgCountAdd 消息未读数量加1
|
|
|
-func MsgCountAdd(userId, msgType, appId string) bool {
|
|
|
+func MsgCountAdd(userId, appId string, msgType int64) bool {
|
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
in := redis.Incr(redisModule, keyString)
|
|
|
FindUserMsg(message.FindUserMsgReq{
|
|
@@ -358,7 +358,7 @@ func MsgCountAdd(userId, msgType, appId string) bool {
|
|
|
}
|
|
|
|
|
|
// MsgCountMinusOne 根据消息类型未读消息数量减1
|
|
|
-func MsgCountMinusOne(userId, msgType, appId string) bool {
|
|
|
+func MsgCountMinusOne(userId, appId string, msgType int64) bool {
|
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
FindUserMsg(message.FindUserMsgReq{
|
|
|
UserId: userId,
|
|
@@ -376,7 +376,7 @@ func MsgCountMinusOne(userId, msgType, appId string) bool {
|
|
|
}
|
|
|
|
|
|
// MsgCountZero 把该消息类型未读数量置0
|
|
|
-func MsgCountZero(userId, msgType, appId string) bool {
|
|
|
+func MsgCountZero(userId, appId string, msgType int64) bool {
|
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
fool := redis.Put(redisModule, keyString, 0, -1)
|
|
|
FindUserMsg(message.FindUserMsgReq{
|
|
@@ -435,7 +435,7 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
|
})
|
|
|
logx.Info("执行事务是否成功:", ok)
|
|
|
if ok {
|
|
|
- ok1 := MsgCountAdd(v, strconv.Itoa(int(this.MsgType)), this.Appid)
|
|
|
+ ok1 := MsgCountAdd(v, this.Appid, this.MsgType)
|
|
|
if !ok1 {
|
|
|
log.Println("存redis:", ok1, v)
|
|
|
}
|
|
@@ -444,7 +444,7 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
|
in := entity.Mysql.InsertBySql(sql3, common.If(positionId != 0, positionId, nil))
|
|
|
logx.Info("插入消息返回 in1 id:", in)
|
|
|
if in > -1 {
|
|
|
- ok := MsgCountAdd(v, strconv.Itoa(int(this.MsgType)), this.Appid)
|
|
|
+ ok := MsgCountAdd(v, this.Appid, this.MsgType)
|
|
|
if !ok {
|
|
|
log.Println("存redis:", ok, v)
|
|
|
}
|