...
|
...
|
@@ -274,7 +274,10 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
log.info("listInboxByTypes updateReadedByUidAndType param is {}", reqVO);
|
|
|
inBoxDao.updateReadedByUidAndType(getTableName(reqVO.getUid()),reqVO.getUid(),reqVO.getType(),DateUtil.getCurrentTimeSecond(),getUnreadBeginTime());
|
|
|
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(reqVO.getUid(),reqVO.getType());
|
|
|
redisTemplate.delete(key);
|
|
|
RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(reqVO.getUid());
|
|
|
RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(reqVO.getUid());
|
|
|
|
|
|
redisTemplate.delete(key, key1, key2);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -410,16 +413,46 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getTotalUnreadEx(int uid) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid);
|
|
|
InBox inbox = redisTemplate.get(inboxKey, InBox.class);
|
|
|
if (null == inbox) {
|
|
|
List<InBox> inBoxes = inBoxDao.selectInboxs(getTableName(uid), null, uid, 0, 1); //查询最新一条未读消息
|
|
|
if(CollectionUtils.isNotEmpty(inBoxes)){
|
|
|
result.put("lastMessage", inBoxes.get(0).getContent());
|
|
|
result.put("createTime", inBoxes.get(0).getCreateTime());
|
|
|
}
|
|
|
redisTemplate.setEx(inboxKey, inBoxes.get(0), CacheEnum.USERS_INBOX_VO_LAST_INFO.getCacheTime());
|
|
|
} else {
|
|
|
result.put("lastMessage", inbox.getContent());
|
|
|
result.put("createTime", inbox.getCreateTime());
|
|
|
}
|
|
|
|
|
|
//查询未读消息总数
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid);
|
|
|
Integer total = redisTemplate.get(inboxTotalKey,Integer.class);
|
|
|
if (null == total) {
|
|
|
int i = inBoxDao.selectTypeCount(getTableName(uid), uid, "N", "N", null, getUnreadBeginTime());
|
|
|
result.put("count", i);
|
|
|
redisTemplate.setEx(inboxTotalKey, i, CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.getCacheTime());
|
|
|
} else {
|
|
|
result.put("count", total);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private void deleteIboxsByRedis(int uid,int type){
|
|
|
log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LIST.generateKey(uid);
|
|
|
redisTemplate.delete(inboxKey);
|
|
|
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
|
|
|
redisTemplate.delete(key);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
|
|
|
redisTemplate.delete(inboxTotalKey);
|
|
|
RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
|
|
|
redisTemplate.delete(inboxTypeTotalKey);
|
|
|
RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid);
|
|
|
RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid);
|
|
|
|
|
|
redisTemplate.delete(inboxKey, key, inboxTotalKey, inboxTypeTotalKey, key1, key2);
|
|
|
}
|
|
|
|
|
|
private String createContent(String template, String params){
|
...
|
...
|
|