|
@@ -351,34 +351,42 @@ func MessageGetLast(this *message.UserMsgListReq) *message.Messages {
|
|
// MsgCountAdd 消息未读数量加1
|
|
// MsgCountAdd 消息未读数量加1
|
|
func MsgCountAdd(userId, appId string, msgType int64) bool {
|
|
func MsgCountAdd(userId, appId string, msgType int64) bool {
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
- in := redis.Incr(redisModule, keyString)
|
|
|
|
- FindUserMsg(message.FindUserMsgReq{
|
|
|
|
- UserId: userId,
|
|
|
|
- Appid: appId,
|
|
|
|
- OffSet: 1,
|
|
|
|
- PageSize: 5,
|
|
|
|
- MsgType: -1,
|
|
|
|
- Read: 0,
|
|
|
|
- }, true)
|
|
|
|
- return in > 0
|
|
|
|
|
|
+ exists, _ := redis.Exists(redisModule, keyString)
|
|
|
|
+ if exists {
|
|
|
|
+ in := redis.Incr(redisModule, keyString)
|
|
|
|
+ FindUserMsg(message.FindUserMsgReq{
|
|
|
|
+ UserId: userId,
|
|
|
|
+ Appid: appId,
|
|
|
|
+ OffSet: 1,
|
|
|
|
+ PageSize: 5,
|
|
|
|
+ MsgType: -1,
|
|
|
|
+ Read: 0,
|
|
|
|
+ }, true)
|
|
|
|
+ return in > 0
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
|
|
|
|
// MsgCountMinusOne 根据消息类型未读消息数量减1
|
|
// MsgCountMinusOne 根据消息类型未读消息数量减1
|
|
func MsgCountMinusOne(userId, appId string, msgType int64) bool {
|
|
func MsgCountMinusOne(userId, appId string, msgType int64) bool {
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
- FindUserMsg(message.FindUserMsgReq{
|
|
|
|
- UserId: userId,
|
|
|
|
- Appid: appId,
|
|
|
|
- OffSet: 1,
|
|
|
|
- PageSize: 5,
|
|
|
|
- MsgType: -1,
|
|
|
|
- Read: 0,
|
|
|
|
- }, true)
|
|
|
|
- if redis.GetInt(redisModule, keyString) <= 0 {
|
|
|
|
- return true
|
|
|
|
|
|
+ exists, _ := redis.Exists(redisModule, keyString)
|
|
|
|
+ if exists {
|
|
|
|
+ FindUserMsg(message.FindUserMsgReq{
|
|
|
|
+ UserId: userId,
|
|
|
|
+ Appid: appId,
|
|
|
|
+ OffSet: 1,
|
|
|
|
+ PageSize: 5,
|
|
|
|
+ MsgType: -1,
|
|
|
|
+ Read: 0,
|
|
|
|
+ }, true)
|
|
|
|
+ if redis.GetInt(redisModule, keyString) <= 0 {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ in := redis.Decrby(redisModule, keyString, 1)
|
|
|
|
+ return in > 0
|
|
}
|
|
}
|
|
- in := redis.Decrby(redisModule, keyString, 1)
|
|
|
|
- return in > 0
|
|
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
|
|
|
|
// MsgCountZero 把该消息类型未读数量置0
|
|
// MsgCountZero 把该消息类型未读数量置0
|