Authored by csgyoho

no message

... ... @@ -43,10 +43,12 @@ public class InBoxServiceImpl implements IInBoxService {
public JSONArray listInboxTypeInfo(ListInboxTypeInfoReqVO reqBO) {
log.info("listInboxTypeInfo begin.param is {}",reqBO);
Integer uid = reqBO.getUid();
//优先从缓存查
JSONArray result = getInboxTypeInfoByRedis(uid);
if(result != null){
return result;
}
//缓存没有则从数据库查
Map<Integer,TypeCountInbox> typeCountMap = inBoxDao.selectTypeCount(getTableName(uid), uid, "N", "N");
result = new JSONArray();
for(InboxTypeEnum typeEnum : InboxTypeEnum.values()) {
... ... @@ -57,6 +59,7 @@ public class InBoxServiceImpl implements IInBoxService {
obj.put("unReadCount", typeCountMap.containsKey(typeEnum.getId()) ? typeCountMap.get(typeEnum.getId()).getCount() : 0);
result.add(obj);
}
//查询结果存入缓存
setInboxTypeInfoByRedis(uid,result);
//添加新用户引导消息
addNewUserGuideMessage(uid);
... ... @@ -70,6 +73,7 @@ public class InBoxServiceImpl implements IInBoxService {
if(inbox != null){
return;
}
//采用异步方式新增消息
Runnable runnable = new Runnable() {
@Override
public void run() {
... ... @@ -121,10 +125,12 @@ public class InBoxServiceImpl implements IInBoxService {
}
//如果根据类型查看,设置未读为已读
updateReaded(reqVO);
//优先从缓存查
PageResponseVO<InBox> response = listInboxByRedis(reqVO);
if(null != response){
return response;
}
//缓存没有则从数据库查
response = new PageResponseVO<>();
int total = inBoxDao.selectTotalInboxs(getTableName(reqVO.getUid()),reqVO.getType(),
reqVO.getUid());
... ... @@ -141,6 +147,7 @@ public class InBoxServiceImpl implements IInBoxService {
response.setPage(reqVO.getPage());
response.setSize(reqVO.getLimit());
response.setTotal(total);
//查询结果存入缓存
setInboxByRedis(reqVO,inBoxes,total);
return response;
}
... ... @@ -198,6 +205,7 @@ public class InBoxServiceImpl implements IInBoxService {
inBox.setContent(createContent(businessTypeEnum.getContent(),params));
inBox.setBusinessType(businessType);
inBoxDao.insertInbox(getTableName(inBox.getUid()),inBox);
//清空redis缓存
deleteIboxsByRedis(uid,type);
}
... ...