|
|
package com.yohobuy.platform.grass.service.impl;
|
|
|
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yohobuy.platform.common.helper.UserHelper;
|
|
|
import com.yohobuy.platform.dal.common.BeanConvertUtil;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao;
|
|
|
import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
|
|
|
import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
|
|
|
import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
|
|
|
import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by shengguo.cai on 2019/1/21.
|
|
|
*/
|
|
|
@Service
|
|
|
public class GrassGoodsCommentServiceImpl implements IGrassGoodsCommentService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentServiceImpl.class);
|
|
|
@Autowired
|
|
|
private IGrassGoodsCommentDao grassGoodsCommentDao;
|
|
|
@Override
|
|
|
public PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req) {
|
|
|
PageResponseVO<GoodsCommentQueryRsp> result = new PageResponseVO<>();
|
|
|
logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
|
|
|
int total = grassGoodsCommentDao.selectTotalByCommentQueryReq(req);
|
|
|
result.setTotal(total);
|
|
|
result.setSize(req.getSize());
|
|
|
result.setPage(req.getPage());
|
|
|
if(total == 0){
|
|
|
return result;
|
|
|
}
|
|
|
List<GoodsCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassGoodsCommentDao.selectByCommentQueryReq(req),GoodsCommentQueryRsp.class);
|
|
|
if(CollectionUtils.isEmpty(commentQueryRspList)){
|
|
|
return result;
|
|
|
}
|
|
|
List<Integer> ids = commentQueryRspList.stream().map(com->com.getId()).collect(Collectors.toList());
|
|
|
Map<Integer,ChildCommentTotalBo> childMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectChildTotalMapByIds(ids),ChildCommentTotalBo.class);
|
|
|
commentQueryRspList.forEach(com->{
|
|
|
ChildCommentTotalBo bo = childMap.get(com.getId());
|
|
|
if(bo != null){
|
|
|
com.setChildTotal(bo.getTotal());
|
|
|
}
|
|
|
});
|
|
|
result.setList(commentQueryRspList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void modifyStatus(GoodsCommentModifyStatusReq req) {
|
|
|
Integer reviewerId = new UserHelper().getUserId();
|
|
|
grassGoodsCommentDao.updateStatus(req.getIds(),req.getStatus(),reviewerId, DateUtil.currentTimeSeconds());
|
|
|
}
|
|
|
} |
|
|
//package com.yohobuy.platform.grass.service.impl;
|
|
|
//
|
|
|
//import com.yoho.core.common.utils.DateUtil;
|
|
|
//import com.yohobuy.platform.common.helper.UserHelper;
|
|
|
//import com.yohobuy.platform.dal.common.BeanConvertUtil;
|
|
|
//import com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao;
|
|
|
//import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
|
|
|
//import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
//import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
|
|
|
//import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
|
|
|
//import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
|
|
|
//import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
|
|
|
//import org.apache.commons.collections.CollectionUtils;
|
|
|
//import org.slf4j.Logger;
|
|
|
//import org.slf4j.LoggerFactory;
|
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
//import org.springframework.stereotype.Service;
|
|
|
//
|
|
|
//import java.util.List;
|
|
|
//import java.util.Map;
|
|
|
//import java.util.stream.Collectors;
|
|
|
//
|
|
|
///**
|
|
|
// * Created by shengguo.cai on 2019/1/21.
|
|
|
// */
|
|
|
//@Service
|
|
|
//public class GrassGoodsCommentServiceImpl implements IGrassGoodsCommentService {
|
|
|
// private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentServiceImpl.class);
|
|
|
// @Autowired
|
|
|
// private IGrassGoodsCommentDao grassGoodsCommentDao;
|
|
|
// @Override
|
|
|
// public PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req) {
|
|
|
// PageResponseVO<GoodsCommentQueryRsp> result = new PageResponseVO<>();
|
|
|
// logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
|
|
|
// int total = grassGoodsCommentDao.selectTotalByCommentQueryReq(req);
|
|
|
// result.setTotal(total);
|
|
|
// result.setSize(req.getSize());
|
|
|
// result.setPage(req.getPage());
|
|
|
// if(total == 0){
|
|
|
// return result;
|
|
|
// }
|
|
|
// List<GoodsCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassGoodsCommentDao.selectByCommentQueryReq(req),GoodsCommentQueryRsp.class);
|
|
|
// if(CollectionUtils.isEmpty(commentQueryRspList)){
|
|
|
// return result;
|
|
|
// }
|
|
|
// List<Integer> ids = commentQueryRspList.stream().map(com->com.getId()).collect(Collectors.toList());
|
|
|
// Map<Integer,ChildCommentTotalBo> childMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectChildTotalMapByIds(ids),ChildCommentTotalBo.class);
|
|
|
// commentQueryRspList.forEach(com->{
|
|
|
// ChildCommentTotalBo bo = childMap.get(com.getId());
|
|
|
// if(bo != null){
|
|
|
// com.setChildTotal(bo.getTotal());
|
|
|
// }
|
|
|
// });
|
|
|
// result.setList(commentQueryRspList);
|
|
|
// return result;
|
|
|
// }
|
|
|
//
|
|
|
// @Override
|
|
|
// public void modifyStatus(GoodsCommentModifyStatusReq req) {
|
|
|
// Integer reviewerId = new UserHelper().getUserId();
|
|
|
// grassGoodsCommentDao.updateStatus(req.getIds(),req.getStatus(),reviewerId, DateUtil.currentTimeSeconds());
|
|
|
// }
|
|
|
//} |
...
|
...
|
|