Authored by mlge

Merge branch 'test6.8.6' of http://git.yoho.cn/platform/platform-cms into test6.8.6

package com.yohobuy.platform.grass.service.impl;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.social.request.BaseReqBO;
import com.yoho.service.model.social.request.UicUserReqBO;
import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yohobuy.platform.common.helper.UserHelper;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao;
... ... @@ -12,13 +16,14 @@ import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
... ... @@ -29,38 +34,97 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
private static final Logger logger = LoggerFactory.getLogger(GrassArticleCommentServiceImpl.class);
@Autowired
private IGrassArticleCommentDao grassArticleCommentDao;
@Autowired
private ServiceCaller serviceCaller;
@Value("${uic.service.url:http://uic.yohoops.org/uic}")
private String uicUrl;
@Override
public PageResponseVO<ArticleCommentQueryRsp> queryComment(ArticleCommentQueryReq req) {
PageResponseVO<ArticleCommentQueryRsp> result = new PageResponseVO<>();
logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
int total = grassArticleCommentDao.selectTotalByCommentQueryReq(req.getStatus(),req.getUid(),req.getDestId(),req.getBeginTime(),req.getEndTime(),
GrassArticleCommentQueryDo.ColumnType.ARTICLE.getValue());
result.setTotal(total);
PageResponseVO<ArticleCommentQueryRsp> result = new PageResponseVO<>();
result.setSize(req.getSize());
result.setPage(req.getPage());
List<Integer> uids = new ArrayList<>();
if(StringUtils.isNotBlank(req.getNickname())){
List<UserInfoRspBO> userInfoRspBOList = queryUsersByNickName(req.getNickname());
List<Integer> cUids = userInfoRspBOList == null ? null : userInfoRspBOList.stream().map(obj ->obj.getYohoUid()).collect(Collectors.toList());
if(CollectionUtils.isEmpty(cUids)){
return result;
}
uids.addAll(cUids);
}
if(req.getUid() != null){
uids.add(req.getUid());
}
uids = uids.isEmpty()?null:uids;
int total = grassArticleCommentDao.selectTotalByCommentQueryReq(req.getStatus(),uids,req.getDestId(),req.getBeginTime(),req.getEndTime(),
GrassArticleCommentQueryDo.ColumnType.ARTICLE.getValue());
result.setTotal(total);
if(total == 0){
return result;
}
List<ArticleCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassArticleCommentDao.selectByCommentQueryReq(req.getStatus(),req.getUid(),req.getDestId(),
List<ArticleCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassArticleCommentDao.selectByCommentQueryReq(req.getStatus(),uids,req.getDestId(),
req.getBeginTime(),req.getEndTime(),GrassArticleCommentQueryDo.ColumnType.ARTICLE.getValue(),req.getStart(),req.getSize()),ArticleCommentQueryRsp.class);
if(CollectionUtils.isEmpty(commentQueryRspList)){
return result;
}
List<Integer> ids = commentQueryRspList.stream().map(com->com.getId()).collect(Collectors.toList());
List<Integer> rspUids = commentQueryRspList.stream().map(comm->comm.getUid()).collect(Collectors.toList());
Map<Integer,UserInfoRspBO> userInfoRspBOMap = getUsersInfo(rspUids);
Map<Integer,ChildCommentTotalBo> childMap = BeanConvertUtil.convertMap(grassArticleCommentDao.selectChildTotalMapByIds(ids),ChildCommentTotalBo.class);
commentQueryRspList.forEach(com->{
ChildCommentTotalBo bo = childMap.get(com.getId());
if(bo != null){
com.setChildTotal(bo.getTotal());
}
UserInfoRspBO userInfoRspBO = userInfoRspBOMap.get(com.getUid());
if(null != userInfoRspBO){
com.setNickname(userInfoRspBO.getNickName());
}
});
result.setList(commentQueryRspList);
return result;
}
//调uic 获取用户的基本信息
private Map<Integer,UserInfoRspBO> getUsersInfo(List<Integer> uidList) {
Map<Integer,UserInfoRspBO> resultMap = new HashMap<>();
String url = uicUrl + "/UserInfoRest/getUserInfoListByYohoUid";
UicUserReqBO req = new UicUserReqBO();
StringBuilder sb = new StringBuilder();
for(Integer u : uidList){
sb.append(u).append(",");
}
String uids = org.apache.commons.lang.StringUtils.removeEnd(sb.toString(), ",");
req.setUids(uids);
logger.info("getUsersInfo uids={}, url={}", uids, url);
UserInfoRspBO[] userBaseInfo = serviceCaller.post("uic.getUserInfoListByYohoUid", url, req, UserInfoRspBO[].class, null).get();
for(UserInfoRspBO bo : userBaseInfo){
resultMap.put(bo.getUid(), bo);
}
return resultMap;
}
private List<UserInfoRspBO> queryUsersByNickName(String nickname){
String url = uicUrl + "/UserInfoRest/getUserInfoByNickName";
BaseReqBO<String> uicReq = new BaseReqBO<>();
uicReq.setParam(nickname);
logger.info("queryUsersByNickName before uic.getUserInfoByNickName, nickName={}, url={}", uicReq.getParam(), url);
UserInfoRspBO[] userInfoRspBOS = serviceCaller.post("uic.getUserInfoByNickName", url, uicReq, UserInfoRspBO[].class, null).get();
if(userInfoRspBOS == null || userInfoRspBOS.length == 0){
return null;
}
//用户的基本信息
List<UserInfoRspBO> userInfoRspBOList = Arrays.asList(userInfoRspBOS);
return userInfoRspBOList;
}
@Override
public void modifyStatus(ArticleCommentModifyStatusReq req) {
Integer reviewerId = new UserHelper().getUserId();
... ...
... ... @@ -33,6 +33,8 @@
<input class="easyui-combobox" id="iptStatus" style="width: 140px">
</input>
<input class="easyui-textbox" id="iptNickname" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptUid" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptArticleId" style="width: 140px">
... ... @@ -46,7 +48,7 @@
</div>
<div style="margin-left: 20px;margin-top: 10px">
<a id="btnBatchAllow" class="btn-long" style="background-color: #5CB85C;">批量通过</a>
<a id="btnBatchBan" class="btn-long" style="background-color: #ffa951;">批量拒绝</a>
<a id="btnBatchBan" class="btn-long" style="background-color: #ffa951;">批量屏蔽</a>
</div>
</div>
... ... @@ -77,7 +79,10 @@
required:false,
prompt: "文章ID"
});
$("#iptNickname").textbox({
required:false,
prompt: "昵称"
});
$("#allBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
... ... @@ -120,6 +125,7 @@
$("#labelGroupListTable").datagrid("load", {
status: status,
uid: $("#iptUid").textbox("getValue"),
nickname:$("#iptNickname").textbox("getValue"),
destId: $("#iptArticleId").textbox("getValue"),
beginTime: startTime,
endTime: endTime
... ... @@ -170,6 +176,12 @@
align: "labelAmount"
},
{
title: "昵称",
field: "nickname",
width: 20,
align: "labelAmount"
},
{
title: "被回复数",
field: "childTotal",
width: 20,
... ... @@ -221,9 +233,6 @@
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.status != 0){
return ;
}
var str = "<a role='allowStatus' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>通过</a>";
str += "<a role='banStatus' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>屏蔽</a>";
return str;
... ...