Authored by csgyoho

Merge branch 'dev_grass_20190108' into test6.8.6

package com.yohobuy.platform.grass.restapi;
import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by shengguo.cai on 2019/1/21.
*/
@RestController
@RequestMapping("/grassGoodsComment")
public class GrassGoodsCommentController {
private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentController.class);
@Autowired
private IGrassGoodsCommentService grassGoodsCommentService;
@RequestMapping("/queryGrassGoodsComment")
@ResponseBody
public ApiResponse queryGrassGoodsComment(GoodsCommentQueryReq req){
logger.info("enter queryGrassGoodsComment.param is {}",req);
PageResponseVO<GoodsCommentQueryRsp> result = grassGoodsCommentService.queryComment(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/modifyGrassGoodsCommentStatus")
@ResponseBody
public ApiResponse modifyGrassGoodsCommentStatus(@RequestBody GoodsCommentModifyStatusReq req){
logger.info("enter modifyGrassGoodsCommentStatus.param is {}",req);
grassGoodsCommentService.modifyStatus(req);
return new ApiResponse.ApiResponseBuilder().message("审核完成").build();
}
}
//package com.yohobuy.platform.grass.restapi;
//
//import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
//import com.yohobuy.platform.model.common.ApiResponse;
//import com.yohobuy.platform.model.common.PageResponseVO;
//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.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * Created by shengguo.cai on 2019/1/21.
// */
//@RestController
//@RequestMapping("/grassGoodsComment")
//public class GrassGoodsCommentController {
// private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentController.class);
// @Autowired
// private IGrassGoodsCommentService grassGoodsCommentService;
//
// @RequestMapping("/queryGrassGoodsComment")
// @ResponseBody
// public ApiResponse queryGrassGoodsComment(GoodsCommentQueryReq req){
// logger.info("enter queryGrassGoodsComment.param is {}",req);
// PageResponseVO<GoodsCommentQueryRsp> result = grassGoodsCommentService.queryComment(req);
// return new ApiResponse.ApiResponseBuilder().data(result).build();
// }
//
// @RequestMapping("/modifyGrassGoodsCommentStatus")
// @ResponseBody
// public ApiResponse modifyGrassGoodsCommentStatus(@RequestBody GoodsCommentModifyStatusReq req){
// logger.info("enter modifyGrassGoodsCommentStatus.param is {}",req);
// grassGoodsCommentService.modifyStatus(req);
// return new ApiResponse.ApiResponseBuilder().message("审核完成").build();
// }
//}
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
/**
* Created by shengguo.cai on 2019/1/21.
*/
public interface IGrassGoodsCommentService {
PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req);
void modifyStatus(GoodsCommentModifyStatusReq req);
}
//package com.yohobuy.platform.grass.service;
//
//import com.yohobuy.platform.model.common.PageResponseVO;
//import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
//import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
//import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
//
///**
// * Created by shengguo.cai on 2019/1/21.
// */
//public interface IGrassGoodsCommentService {
// PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req);
//
// void modifyStatus(GoodsCommentModifyStatusReq req);
//}
... ...
... ... @@ -4,6 +4,7 @@ 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.IGrassArticleCommentDao;
import com.yohobuy.platform.dal.grass.model.GrassArticleCommentQueryDo;
import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
... ... @@ -33,14 +34,17 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
public PageResponseVO<ArticleCommentQueryRsp> queryComment(ArticleCommentQueryReq req) {
PageResponseVO<ArticleCommentQueryRsp> result = new PageResponseVO<>();
logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
int total = grassArticleCommentDao.selectTotalByCommentQueryReq(req);
int total = grassArticleCommentDao.selectTotalByCommentQueryReq(req.getStatus(),req.getUid(),req.getDestId(),req.getBeginTime(),req.getEndTime(),
GrassArticleCommentQueryDo.ColumnType.ARTICLE.getValue());
result.setTotal(total);
result.setSize(req.getSize());
result.setPage(req.getPage());
if(total == 0){
return result;
}
List<ArticleCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassArticleCommentDao.selectByCommentQueryReq(req),ArticleCommentQueryRsp.class);
List<ArticleCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassArticleCommentDao.selectByCommentQueryReq(req.getStatus(),req.getUid(),req.getDestId(),
req.getBeginTime(),req.getEndTime(),GrassArticleCommentQueryDo.ColumnType.ARTICLE.getValue(),req.getStart(),req.getSize()),ArticleCommentQueryRsp.class);
if(CollectionUtils.isEmpty(commentQueryRspList)){
return result;
}
... ...
... ... @@ -10,10 +10,7 @@ import com.yohobuy.platform.common.exception.PlatformException;
import com.yohobuy.platform.common.helper.ImagesHelper;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.*;
import com.yohobuy.platform.dal.grass.model.GrassArticle;
import com.yohobuy.platform.dal.grass.model.GrassArticleBlock;
import com.yohobuy.platform.dal.grass.model.GrassArticleProduct;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.dal.grass.model.*;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
... ... @@ -50,6 +47,9 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Resource
private IGrassTopicDAO grassTopicDAO;
@Resource
private IGrassArticleLabelDao grassArticleLabelDao;
@Autowired
private ServiceCaller serviceCaller;
... ... @@ -310,13 +310,19 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
//审核 通过--不通过
if(type == 2){
Integer authStatus = req.getAuthStatus();;
Integer authStatus = req.getAuthStatus();
Integer articleId = req.getArticleId();
GrassArticle grassArticle = new GrassArticle();
grassArticle.setId(req.getArticleId());
grassArticle.setId(articleId);
grassArticle.setAuthStatus(authStatus);
grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
grassArticle.setAuthTime(System.currentTimeMillis());
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
//审核通过 或者不通过 需要修改article_label表--便于前台标签相关的文章 分页查询
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
grassArticleLabel.setArticleId(articleId);
grassArticleLabel.setAuthStatus(authStatus);//审核状态
grassArticleLabelDao.updateByPrimaryKeySelective(grassArticleLabel);
logger.info("updateArticle changeAuthStatus success! req={}",req);
}
... ...
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());
// }
//}
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.core.common.helpers.ImagesHelper;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.platform.common.convert.BeanConvert;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao;
import com.yohobuy.platform.dal.grass.IGrassGoodsDao;
... ... @@ -58,21 +59,22 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
PageResponseVO<GoodsQueryRsp> result = new PageResponseVO<>();
result.setPage(req.getPage());
result.setSize(req.getSize());
int total = grassGoodsDao.selectTotalByGoodsQueryReq(req);
int total = grassGoodsDao.selectTotalByGoodsQueryReq(req.getSkn());
result.setTotal(total);
if(total == 0){
logger.info("queryGoods#selectTotalByGoodsQueryReq total is 0.param is {}",req);
return result;
}
List<GoodsQueryRsp> goodsBoList = BeanConvertUtil.convertList(grassGoodsDao.selectByGoodsQueryReq(req),GoodsQueryRsp.class);
List<GoodsQueryRsp> goodsBoList = BeanConvertUtil.convertList(grassGoodsDao.selectByGoodsQueryReq(req.getSkn(),req.getStart(),req.getSize()),GoodsQueryRsp.class);
if(CollectionUtils.isEmpty(goodsBoList)){
logger.info("queryGoods#selectByGoodsQueryReq goodsBoList is empty.param is {}",req);
return result;
}
// 查询评论总数
List<Integer> goodsIds = goodsBoList.stream().map(goods->goods.getId()).collect(Collectors.toList());
Map<Integer,GoodsCommentTotalBo> commentMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectTotalMapByGoodsIds(goodsIds),GoodsCommentTotalBo.class);
// 查询商品信息
//TODO 查询评论合并了 Map<Integer,GoodsCommentTotalBo> commentMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectTotalMapByGoodsIds(goodsIds),GoodsCommentTotalBo.class);
Map<Integer,GoodsCommentTotalBo> commentMap = null;//TODO 查询评论后期实现
// 查询商品信息
String skns = goodsBoList.stream().filter(goods-> StringUtils.isNotBlank(goods.getProductSkn())).map(goods->goods.getProductSkn()).collect(Collectors.joining(","));
Map<String,JSONObject> productMap = buildProductMap(skns,1);
// 组装返回
... ... @@ -116,9 +118,9 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
if(CollectionUtils.isEmpty(reqList)){
throw new ServiceException(400,"param is empty!");
}
initAddGoodsContent(reqList);
int createTime = DateUtil.getCurrentTimeSecond();
grassGoodsDao.insertByBatchAddGoodsReq(reqList,createTime);
List<GrassGoods> goodsList = BeanConvertUtil.convertList(reqList,GrassGoods.class);
initAddGoodsContent(goodsList);
grassGoodsDao.insertByBatchAddGoodsReq(goodsList);
}
@Override
... ... @@ -134,7 +136,8 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
throw new ServiceException(400,"some params are null!");
}
req.setUpdateTime(DateUtil.getCurrentTimeSecond());
grassGoodsDao.updateByGoodsModifyReq(req);
GrassGoods grassGoods = BeanConvert.copyBeans(GrassGoods.class,req);
grassGoodsDao.updateByGoodsModifyReq(grassGoods);
}
@Override
... ... @@ -142,8 +145,9 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
grassGoodsDao.updateStatus(status,id,DateUtil.getCurrentTimeSecond());
}
private void initAddGoodsContent(List<BatchAddGoodsReq> reqList) {
List<Integer> skns = reqList.stream().map(req->req.getSkn()).collect(Collectors.toList());
private void initAddGoodsContent(List<GrassGoods> reqList) {
int createTime = DateUtil.getCurrentTimeSecond();
List<Integer> skns = reqList.stream().map(req->Integer.valueOf(req.getProductSkn())).collect(Collectors.toList());
logger.info("initAddGoodsContent#before selectProductBySkns,skns is {}",skns);
List<Product> productList = productMapper.selectProductBySkns(skns);
if(CollectionUtils.isEmpty(productList)){
... ... @@ -153,7 +157,8 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
Map<Integer,String> productContentMap = new HashMap<>();
productList.stream().forEach(product -> {productContentMap.put(product.getErpProductId(),product.getPhrase());});
reqList.stream().forEach(req->{
req.setContent(productContentMap.get(req.getSkn()));
req.setContent(productContentMap.get(req.getProductSkn()));
req.setCreateTime(createTime);
});
}
... ...
... ... @@ -347,6 +347,8 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
- com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO
- com.yohobuy.platform.dal.grass.IGrassArticleLabelDao
... ...
... ... @@ -345,6 +345,7 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
- com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO
- com.yohobuy.platform.dal.grass.IGrassArticleLabelDao
yhb_promotion:
servers:
- ${jdbc.mysql.yhbpromotion.master}
... ...
... ... @@ -248,6 +248,12 @@
str += "<a role='switchR' class='btn-success' dataId='"+rowData.articleId+"' status='1' style='margin-left:10px'>审核通过</a>";
str += "<a role='switchR' class='btn-success' dataId='"+rowData.articleId+"' status='2' style='margin-left:10px'>不通过</a>";
}
if(rowData.authStatus==1){//审核通过了--允许驳回
str += "<a role='switchR' class='btn-success' dataId='"+rowData.articleId+"' status='2' style='margin-left:10px'>不通过</a>";
}
if(rowData.authStatus==2){//审核不通过的--允许通过
str += "<a role='switchR' class='btn-success' dataId='"+rowData.articleId+"' status='1' style='margin-left:10px'>审核通过</a>";
}
//还有一个编辑按钮
return str;
}
... ...
... ... @@ -75,7 +75,7 @@
});
$("#iptArticleId").numberbox({
required:false,
prompt: "原内容ID"
prompt: "文章ID"
});
$("#allBtn").linkbutton({
... ... @@ -120,7 +120,7 @@
$("#labelGroupListTable").datagrid("load", {
status: status,
uid: $("#iptUid").textbox("getValue"),
articleId: $("#iptArticleId").textbox("getValue"),
destId: $("#iptArticleId").textbox("getValue"),
beginTime: startTime,
endTime: endTime
});
... ... @@ -158,22 +158,8 @@
align: "left"
},
{
title: "原文类型",
field: "columnType",
width: 15,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(value == '1000'){
return "文章";
}
if(value == '1001'){
return "晒单";
}
}
},
{
title: "晒单ID",
field: "shareOrderId",
title: "文章ID",
field: "destId",
width: 20,
align: "labelAmount"
},
... ...