先來看看功能的需求
跟微信朋友圈一樣的功能。
我是分步驟做:
1:先查看朋友圈。查看的都是自己的好友。點贊和評論是好友才能看見。不是好友就隱藏看下圖。三個不用的用戶登錄
在展示的接口我先查詢出當前好友的點贊和評論的用戶集合。
doctorId = inputFields.doctorId; //當前醫生人
partyIds.add(doctorId);
andExprs = FastList.newInstance();
andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, doctorId));
//查詢用戶屏蔽的人
if("appTypeEnum_0".equals(partyClient)){
shieldingPartys = ParameterSettingServices.getShieldingParty(delegator,doctorId,inputFields.partyClient);
if(shieldingPartys)
andExprs.add(EntityCondition.makeCondition("friendId", EntityOperator.NOT_IN, shieldingPartys));
}
andExprs.add(EntityCondition.makeCondition("addStatusEnum", EntityOperator.EQUALS, "addStatusEnum_2"));
andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andExprs.add(EntityCondition.makeCondition("partyClient", EntityOperator.EQUALS, inputFields.partyClient));
andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
//我的好友(不再黑名單中的)
myFriendsList = delegator.findList("MyFriends",andCond, UtilMisc.toSet("friendId"), null, null, true);//非我屏蔽的好友;
andExprs = FastList.newInstance();
if("appTypeEnum_0".equals(partyClient)){
shieldingPartys = ParameterSettingServices.getShieldingParty(delegator,doctorId,inputFields.partyClient);
if(shieldingPartys)
andExprs.add(EntityCondition.makeCondition("beConcernId", EntityOperator.NOT_IN, shieldingPartys));
}
andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, doctorId));
andExprs.add(EntityCondition.makeCondition("partyClient", EntityOperator.EQUALS, inputFields.partyClient));
andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
//我關注的人(不再黑名單中的)
// concernList = delegator.findList("Concern",andCond, UtilMisc.toSet("beConcernId"), null, null, true);
//
// if(concernList){
// beConcernIdList = EntityUtil.getFieldListFromEntityList(concernList, "beConcernId", true);//非我屏蔽的我關注的人
// if(beConcernIdList){
// partyIds.addAll(beConcernIdList);
// }
// }
if(myFriendsList){
friendIdList = EntityUtil.getFieldListFromEntityList(myFriendsList, "friendId", true);
if(friendIdList){
partyIds.addAll(friendIdList);
}
}
//我的好友和我關注的人(非黑名單中的)去重
partyIds = new ArrayList(new HashSet(partyIds));
partyIds是當前醫生的好友和關注列表 對比 如果是好友相同的則顯示
然后查找我的關注和我的好友 列表集合
//當前登錄人不為空
loginId=partyId;//當前登錄人
/**
* 當前登錄人的好友和關注列表
*/
loginIds.add(loginId);
andExprse = FastList.newInstance();
andExprse.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, loginId));
//查詢用戶屏蔽的人
if("appTypeEnum_0".equals(partyClient)){
shieldingPartys = ParameterSettingServices.getShieldingParty(delegator,loginId,inputFields.partyClient);
if(shieldingPartys)
andExprse.add(EntityCondition.makeCondition("friendId", EntityOperator.NOT_IN, shieldingPartys));
}
andExprse.add(EntityCondition.makeCondition("addStatusEnum", EntityOperator.EQUALS, "addStatusEnum_2"));
andExprse.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andExprse.add(EntityCondition.makeCondition("partyClient", EntityOperator.EQUALS, inputFields.partyClient));
andConds = EntityCondition.makeCondition(andExprse, EntityOperator.AND);
//當前登錄人的我的好友(不再黑名單中的)
LoginFriendsList = delegator.findList("MyFriends",andConds, UtilMisc.toSet("friendId"), null, null, true);//非我屏蔽的好友;
andExprse = FastList.newInstance();
if("appTypeEnum_0".equals(partyClient)){
shieldingPartys = ParameterSettingServices.getShieldingParty(delegator,loginId,inputFields.partyClient);
if(shieldingPartys)
andExprse.add(EntityCondition.makeCondition("beConcernId", EntityOperator.NOT_IN, shieldingPartys));
}
andExprse.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, loginId));
andExprse.add(EntityCondition.makeCondition("partyClient", EntityOperator.EQUALS, inputFields.partyClient));
andExprse.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andConds = EntityCondition.makeCondition(andExprse, EntityOperator.AND);
//我關注的人(不再黑名單中的)
loginConcernList = delegator.findList("Concern",andConds, UtilMisc.toSet("beConcernId"), null, null, true);
if(loginConcernList){
beConcernIdList = EntityUtil.getFieldListFromEntityList(loginConcernList, "beConcernId", true);//非我屏蔽的我關注的人
if(beConcernIdList){
loginIds.addAll(beConcernIdList);
}
}
if(LoginFriendsList){
friendIdList = EntityUtil.getFieldListFromEntityList(LoginFriendsList, "friendId", true);
if(friendIdList){
loginIds.addAll(friendIdList);
}
}
//我的好友和我關注的人(非黑名單中的)去重
loginIds = new ArrayList(new HashSet(loginIds));
loginIds是當前的登錄人的好友和關注列表
根據partyIdse來進行篩選 這個集合代表的共同好友集合。共同好友才會顯示 評論或贊
//loginIds是當前的登錄人的好友和關注列表 partyIds是當前醫生的好友和關注列表 對比 如果是好友相同的則顯示。
for(int i=0;i<loginIds.size();i++){
for(int j=0;j<partyIds.size();j++){
if(loginIds[i]==partyIds[j]){
partyIdse.add(partyIds[j]);
}
}
}
最后得到兩個集合的數據並返回
//評論集合
andExprs = FastList.newInstance();
andExprs.add(EntityCondition.makeCondition("caseHisTopId", EntityOperator.EQUALS, result.caseHisTopId));
andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andExprs.add(EntityCondition.makeCondition("reviewTypeEnum", EntityOperator.EQUALS, "reviewTypeEnum_1"));
andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.IN,partyIdse));
andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
Set set=["content","partyName","partyheadUrl","partyId","caseHisTopRevId","caseHisTopId","reviewTypeEnum","levelEnum","replyId","replyTopRevId"];
reviewList = delegator.findList("CaseHisTopReviewAndParty",andCond,set, null, null, false);//非我屏蔽的好友;
result.reviewList=org.extErp.sysCommon.util.JsonUtil.jsonFromGenericValueList(reviewList);
//得到被回復人的信息
if(result.reviewList){
for(Map<String,Object> review:result.reviewList){
if(review.replyId){
gvList = delegator.findList("Party",EntityCondition.makeCondition("partyId", EntityOperator.EQUALS,review.replyId),UtilMisc.toSet("partyheadUrl","partyName"), null, null, true);
if(gvList){
gv = EntityUtil.getFirst(gvList);
}
review.gv=gv;
}
}
}
//點贊集合
andExprs = FastList.newInstance();
andExprs.add(EntityCondition.makeCondition("caseHisTopId", EntityOperator.EQUALS, result.caseHisTopId));
andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
andExprs.add(EntityCondition.makeCondition("reviewTypeEnum", EntityOperator.EQUALS, "reviewTypeEnum_2"));
andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.IN,partyIdse));
andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
// praiseList = delegator.findByAndCache("CaseHisTopReviewAndParty",["caseHisTopId":result.caseHisTopId,"thruDate":null,"reviewTypeEnum":"reviewTypeEnum_2"],null);
praiseList = delegator.findList("CaseHisTopReviewAndParty",andCond, UtilMisc.toSet("content","partyName","partyheadUrl","partyId","caseHisTopRevId","caseHisTopId","reviewTypeEnum","levelEnum"), null, null, true);//非我屏蔽的好友;
if(praiseList){
result.praiseList=org.extErp.sysCommon.util.JsonUtil.jsonFromGenericValueList(praiseList);
}
這是只是查看朋友圈。下一篇是消息推送之類的。 轉載請注明出處:http://www.cnblogs.com/huole/p/5757730.html
