实现类似微信朋友圈功能(一 )只供自己好友可见的点赞和评论
先来看看功能的需求
跟微信朋友圈一样的功能。
我是分步骤做:
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