...
|
...
|
@@ -14,6 +14,7 @@ import com.yoho.service.model.social.response.UserInfoRspBO; |
|
|
import com.yohobuy.platform.common.enums.ArticleTypeEnum;
|
|
|
import com.yohobuy.platform.common.exception.PlatformException;
|
|
|
import com.yohobuy.platform.common.helper.ImagesHelper;
|
|
|
import com.yohobuy.platform.common.util.CollectionUtil;
|
|
|
import com.yohobuy.platform.common.util.DateUtil;
|
|
|
import com.yohobuy.platform.dal.grass.*;
|
|
|
import com.yohobuy.platform.dal.grass.model.*;
|
...
|
...
|
@@ -22,6 +23,7 @@ import com.yohobuy.platform.dal.guang.model.Author; |
|
|
import com.yohobuy.platform.grass.service.IGrassArticleService;
|
|
|
import com.yohobuy.platform.grass.service.IGrassRefreshCacheService;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
import com.yohobuy.platform.model.grass.request.GrassArticleProductBo;
|
|
|
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
|
|
|
import com.yohobuy.platform.model.grass.request.GrassCacheReq;
|
|
|
import com.yohobuy.platform.model.grass.response.ArticleDetailRspBo;
|
...
|
...
|
@@ -99,10 +101,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
|
|
|
List<Integer> labels = Lists.newArrayList();
|
|
|
String[] urls = req.getArticleImages().split(",");
|
|
|
String[] skns = null;
|
|
|
if(StringUtils.isNotEmpty(req.getArticleSkns())){
|
|
|
skns = req.getArticleSkns().split(",");
|
|
|
if(skns.length > 10){
|
|
|
if(CollectionUtils.isNotEmpty(req.getProducts())){
|
|
|
if(req.getProducts().size() > 10){
|
|
|
logger.info("publishArticle , article products more than most publish number");
|
|
|
throw new PlatformException("publish products most number is 10 ", 405);
|
|
|
}
|
...
|
...
|
@@ -163,21 +163,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
}
|
|
|
|
|
|
try{
|
|
|
if(StringUtils.isNotEmpty( req.getArticleSkns())){
|
|
|
if(CollectionUtils.isNotEmpty( req.getProducts())){
|
|
|
int orderby = 0;
|
|
|
List<GrassArticleProduct> sknList = Lists.newArrayList();
|
|
|
if(skns != null){
|
|
|
Integer sknType = Optional.ofNullable(req.getSknType()).orElse(1);
|
|
|
for (String skn: skns) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(article.getId());
|
|
|
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
|
|
|
grassArticleSkn.setCreateTime(now);
|
|
|
grassArticleSkn.setOrderBy(orderby);
|
|
|
grassArticleSkn.setProductSource(sknType);
|
|
|
orderby++;
|
|
|
sknList.add(grassArticleSkn);
|
|
|
}
|
|
|
for (GrassArticleProductBo skn: req.getProducts()) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(article.getId());
|
|
|
grassArticleSkn.setProductSkn(skn.getProductSkn());
|
|
|
grassArticleSkn.setCreateTime(now);
|
|
|
grassArticleSkn.setOrderBy(orderby);
|
|
|
grassArticleSkn.setProductSource(skn.getProductType());
|
|
|
orderby++;
|
|
|
sknList.add(grassArticleSkn);
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(sknList)){
|
...
|
...
|
@@ -465,70 +462,6 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
}
|
|
|
//编辑文章 没地方用到
|
|
|
if(type == 1){
|
|
|
Integer articleId = req.getArticleId();
|
|
|
if(articleId == null){
|
|
|
throw new PlatformException("articleId is null", 402);
|
|
|
}
|
|
|
//修改文章主体内容
|
|
|
if(req.getTopicId() !=null){
|
|
|
GrassArticle grassArticle = new GrassArticle();
|
|
|
grassArticle.setId(articleId);
|
|
|
grassArticle.setUpdateTime(System.currentTimeMillis());
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
}
|
|
|
|
|
|
//文章内容
|
|
|
grassArticleBlockDao.deleteByArticleId(articleId);
|
|
|
|
|
|
//图片内容
|
|
|
List<String> reqlist = req.getArticleImages() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleImages().split(","));
|
|
|
//新增
|
|
|
List<GrassArticleBlock> addList = Lists.newArrayList();
|
|
|
int contentOrder = 0;
|
|
|
for (String src : reqlist) {
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(articleId);
|
|
|
content.setContentData(getBlock(BLOCK_IMAGE,src));
|
|
|
content.setCreateTime(System.currentTimeMillis());
|
|
|
content.setTemplateKey("image");
|
|
|
content.setOrderBy(contentOrder);
|
|
|
contentOrder++;
|
|
|
addList.add(content);
|
|
|
}
|
|
|
//文字内容
|
|
|
if(StringUtils.isNotEmpty(req.getContent())){
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(articleId);
|
|
|
content.setContentData(getBlock(BLOCK_TEXT,req.getContent()));
|
|
|
content.setCreateTime(System.currentTimeMillis());
|
|
|
content.setTemplateKey("text");
|
|
|
content.setOrderBy(contentOrder);
|
|
|
addList.add(content);
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(addList)){
|
|
|
grassArticleBlockDao.insertArticleContents(addList);
|
|
|
updateArticleImageSize(articleId);
|
|
|
}
|
|
|
|
|
|
//商品
|
|
|
grassArticleProductDao.deleteByArticleId(articleId);
|
|
|
List<String> reqSknlist = req.getArticleSkns() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
|
|
|
//新增
|
|
|
List<GrassArticleProduct> addSknList = Lists.newArrayList();
|
|
|
int orderBy = 0;
|
|
|
for (String skn : reqSknlist) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(articleId);
|
|
|
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
|
|
|
grassArticleSkn.setCreateTime(System.currentTimeMillis());
|
|
|
grassArticleSkn.setOrderBy(orderBy);
|
|
|
orderBy++;
|
|
|
addSknList.add(grassArticleSkn);
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(addSknList)){
|
|
|
grassArticleProductDao.insertArticleSkns(addSknList);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -776,19 +709,21 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
|
|
|
//商品
|
|
|
grassArticleProductDao.deleteByArticleId(articleId);
|
|
|
List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
|
|
|
// List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
|
|
|
//新增
|
|
|
List<GrassArticleProduct> addSknList = Lists.newArrayList();
|
|
|
int orderBy = 0;
|
|
|
for (String skn : reqSknlist) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(articleId);
|
|
|
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
|
|
|
grassArticleSkn.setCreateTime(System.currentTimeMillis());
|
|
|
grassArticleSkn.setOrderBy(orderBy);
|
|
|
grassArticleSkn.setProductSource(req.getSknType());
|
|
|
orderBy++;
|
|
|
addSknList.add(grassArticleSkn);
|
|
|
if(CollectionUtils.isNotEmpty(req.getProducts())){
|
|
|
for (GrassArticleProductBo skn : req.getProducts()) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(articleId);
|
|
|
grassArticleSkn.setProductSkn(skn.getProductSkn());
|
|
|
grassArticleSkn.setCreateTime(System.currentTimeMillis());
|
|
|
grassArticleSkn.setOrderBy(orderBy);
|
|
|
grassArticleSkn.setProductSource(skn.getProductType());
|
|
|
orderBy++;
|
|
|
addSknList.add(grassArticleSkn);
|
|
|
}
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(addSknList)){
|
|
|
grassArticleProductDao.insertArticleSkns(addSknList);
|
...
|
...
|
@@ -867,10 +802,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
|
|
|
List<Integer> labels = Lists.newArrayList();
|
|
|
String[] urls = req.getArticleImages().split(",");
|
|
|
String[] skns = null;
|
|
|
if(StringUtils.isNotEmpty(req.getArticleSkns())){
|
|
|
skns = req.getArticleSkns().split(",");
|
|
|
if(skns.length > 10){
|
|
|
if(CollectionUtils.isNotEmpty(req.getProducts())){
|
|
|
if(req.getProducts().size() > 10){
|
|
|
logger.info("timerPublish , article products more than most publish number");
|
|
|
throw new PlatformException("publish products most number is 10 ", 405);
|
|
|
}
|
...
|
...
|
@@ -930,21 +863,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
}
|
|
|
|
|
|
try{
|
|
|
if(StringUtils.isNotEmpty( req.getArticleSkns())){
|
|
|
if(CollectionUtils.isNotEmpty(req.getProducts())){
|
|
|
int orderby = 0;
|
|
|
List<GrassArticleProduct> sknList = Lists.newArrayList();
|
|
|
if(skns != null){
|
|
|
Integer sknType = Optional.ofNullable(req.getSknType()).orElse(1);
|
|
|
for (String skn: skns) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(article.getId());
|
|
|
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
|
|
|
grassArticleSkn.setCreateTime(time);
|
|
|
grassArticleSkn.setOrderBy(orderby);
|
|
|
grassArticleSkn.setProductSource(sknType);
|
|
|
orderby++;
|
|
|
sknList.add(grassArticleSkn);
|
|
|
}
|
|
|
for (GrassArticleProductBo skn: req.getProducts()) {
|
|
|
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
grassArticleSkn.setArticleId(article.getId());
|
|
|
grassArticleSkn.setProductSkn(skn.getProductSkn());
|
|
|
grassArticleSkn.setCreateTime(time);
|
|
|
grassArticleSkn.setOrderBy(orderby);
|
|
|
grassArticleSkn.setProductSource(skn.getProductSkn());
|
|
|
orderby++;
|
|
|
sknList.add(grassArticleSkn);
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(sknList)){
|
...
|
...
|
@@ -1175,8 +1105,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
});
|
|
|
Map<Integer, List<String>> imgMap = Maps.newHashMap();
|
|
|
Map<Integer,String> textMap = Maps.newHashMap();
|
|
|
Map<Integer, List<Integer>> sknMap = Maps.newHashMap();
|
|
|
Map<Integer, Integer> sknTypeMap = Maps.newHashMap();
|
|
|
Map<Integer, List<GrassArticleProductBo>> sknMap = Maps.newHashMap();
|
|
|
Map<Integer, List<JSONObject>> labelMap = buildLabelInfoMap(labelList);
|
|
|
Map<Integer, GrassTopic> topicMap = buildTopicInfoMap(grassArticleTopics);
|
|
|
grassArticleContentList.forEach(content -> {
|
...
|
...
|
@@ -1200,13 +1129,15 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
});
|
|
|
|
|
|
grassArticlePoductList.forEach(product -> {
|
|
|
List<Integer> skns = sknMap.get(product.getArticleId());
|
|
|
List<GrassArticleProductBo> skns = sknMap.get(product.getArticleId());
|
|
|
if (skns == null) {
|
|
|
skns = Lists.newArrayList();
|
|
|
}
|
|
|
skns.add(product.getProductSkn());
|
|
|
GrassArticleProductBo bo = new GrassArticleProductBo();
|
|
|
bo.setProductSkn(product.getProductSkn());
|
|
|
bo.setProductType(product.getProductSource());
|
|
|
skns.add(bo);
|
|
|
sknMap.put(product.getArticleId(), skns);
|
|
|
sknTypeMap.put(product.getArticleId(), product.getProductSource());
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
@@ -1246,8 +1177,12 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
rspBo.setIsTop(article.getIsTop());
|
|
|
rspBo.setIsRecommend(article.getIsRecommend());
|
|
|
rspBo.setAuthorizeAccount(article.getAuthorizeAccount());
|
|
|
rspBo.setSknList(sknMap.get(article.getId()));
|
|
|
rspBo.setSknType(sknTypeMap.get(article.getId()));
|
|
|
List<GrassArticleProductBo> productBos = sknMap.get(article.getId());
|
|
|
if(CollectionUtils.isNotEmpty(productBos)){
|
|
|
rspBo.setSknList(productBos);
|
|
|
rspBo.setYohoList(productBos.stream().filter(x -> x.getProductType()==1).map(GrassArticleProductBo::getProductSkn).collect(Collectors.toList()));
|
|
|
rspBo.setUfoList(productBos.stream().filter(x -> x.getProductType()==2).map(GrassArticleProductBo::getProductSkn).collect(Collectors.toList()));
|
|
|
}
|
|
|
Long authTime = article.getAuthTime();
|
|
|
rspBo.setAuthTimeStr(DateUtil.long2DateStr(authTime, DateUtil.DATE_TIME_FORMAT));
|
|
|
rspBo.setRecomTimeStr(DateUtil.long2DateStr(article.getRecommendTime(), DateUtil.DATE_TIME_FORMAT));
|
...
|
...
|
|