...
|
...
|
@@ -18,6 +18,7 @@ import com.yohoufo.user.requestVO.ListInboxReqVO; |
|
|
import com.yohoufo.user.requestVO.ListInboxTypeInfoReqVO;
|
|
|
import com.yohoufo.user.responseVO.PageResponseVO;
|
|
|
import com.yohoufo.user.service.IInBoxService;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -43,6 +44,13 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
public JSONArray listInboxTypeInfo(ListInboxTypeInfoReqVO reqBO) {
|
|
|
log.info("listInboxTypeInfo begin.param is {}",reqBO);
|
|
|
Integer uid = reqBO.getUid();
|
|
|
JSONArray result = getInboxTypeInfo(uid);
|
|
|
//添加新用户引导消息
|
|
|
addNewUserGuideMessage(uid);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private JSONArray getInboxTypeInfo(int uid){
|
|
|
//优先从缓存查
|
|
|
JSONArray result = getInboxTypeInfoByRedis(uid);
|
|
|
if(result != null){
|
...
|
...
|
@@ -61,8 +69,6 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
}
|
|
|
//查询结果存入缓存
|
|
|
setInboxTypeInfoByRedis(uid,result);
|
|
|
//添加新用户引导消息
|
|
|
addNewUserGuideMessage(uid);
|
|
|
return result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -209,6 +215,36 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
deleteIboxsByRedis(uid,type);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getTotalUnread(int uid) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
//查询最新一条未读消息
|
|
|
ListInboxReqVO vo = new ListInboxReqVO();
|
|
|
vo.setUid(uid);
|
|
|
vo.setPage(1);
|
|
|
vo.setLimit(1);
|
|
|
PageResponseVO<InBox> inBoxVo = listInboxByTypes(vo);
|
|
|
if(inBoxVo != null && !CollectionUtils.isEmpty(inBoxVo.getList())){
|
|
|
result.put("lastMessage",inBoxVo.getList().get(0).getContent());
|
|
|
}
|
|
|
//查询未读消息总数
|
|
|
JSONArray inboxTypeInfo = getInboxTypeInfo(uid);
|
|
|
if(CollectionUtils.isEmpty(inboxTypeInfo)){
|
|
|
result.put("count",0);
|
|
|
}else{
|
|
|
int total=0;
|
|
|
for(Object obj : inboxTypeInfo){
|
|
|
JSONObject jsonObject = (JSONObject)obj;
|
|
|
Integer count = (Integer)jsonObject.get("unReadCount");
|
|
|
if(count != null){
|
|
|
total +=count;
|
|
|
}
|
|
|
}
|
|
|
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_LIST.generateKey(uid);
|
...
|
...
|
|