...
|
...
|
@@ -346,7 +346,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
}
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
//推荐和置顶操作,清前台缓存
|
|
|
clearArticleListCache();
|
|
|
clearArticleListCache(req.getArticleId());
|
|
|
}
|
|
|
//编辑文章 没地方用到
|
|
|
if(type == 1){
|
...
|
...
|
@@ -451,6 +451,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
|
|
|
grassArticle.setAuthTime(time);
|
|
|
grassArticle.setCreateTime(time);
|
|
|
grassArticle.setIsRecommend(1);
|
|
|
grassArticle.setRecommendTime(time);
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
|
|
grassArticleLabel.setArticleId(articleId);
|
...
|
...
|
@@ -469,6 +471,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
grassArticle.setAuthorizeAccount("");
|
|
|
grassArticle.setAuthTime(0L);
|
|
|
grassArticle.setCreateTime(0L);
|
|
|
grassArticle.setIsRecommend(0);
|
|
|
grassArticle.setRecommendTime(0L);
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
|
|
grassArticleLabel.setArticleId(articleId);
|
...
|
...
|
@@ -684,6 +688,140 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void timerPublish(GrassArticleReq req) throws PlatformException {
|
|
|
logger.info("enter timerPublish, req is {}", req);
|
|
|
publishCheck(req);
|
|
|
|
|
|
String publishTime = req.getPublishTime();
|
|
|
if(StringUtils.isEmpty(publishTime)){
|
|
|
throw new PlatformException("publishTime is null", 402);
|
|
|
}
|
|
|
long time = Long.valueOf(publishTime)+ new Random().nextInt(999);
|
|
|
|
|
|
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 > 5){
|
|
|
logger.info("timerPublish , article products more than most publish number");
|
|
|
throw new PlatformException("publish products most number is 5 ", 405);
|
|
|
}
|
|
|
}
|
|
|
if(urls.length > 9){
|
|
|
logger.info("timerPublish , article images more than most publish number");
|
|
|
throw new PlatformException("publish images most number is 9 ", 405);
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(req.getLabelIds())){
|
|
|
labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
if(labels.size() > 5){
|
|
|
logger.info("timerPublish , article labels more than most publish number");
|
|
|
throw new PlatformException("publish labels most number is 5 ", 405);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
GrassArticle article = new GrassArticle();
|
|
|
article.setAuthorUid(req.getAuthorUid());
|
|
|
article.setCreateTime(time);
|
|
|
article.setAuthStatus(1);
|
|
|
article.setAuthTime(time);
|
|
|
try{
|
|
|
grassArticleDao.insertArticleSeletive(article);
|
|
|
logger.info("insert grass article success, uid is {}, ariticle id is {}", article.getAuthorUid(), article.getId());
|
|
|
}catch (Exception e){
|
|
|
logger.warn("insert grass article fail, uid is {}, e is {}",req.getAuthorUid(), e );
|
|
|
throw new PlatformException("timerPublish article failed", 402);
|
|
|
}
|
|
|
|
|
|
try{
|
|
|
List<GrassArticleBlock> contentList = Lists.newArrayList();
|
|
|
int contentOrder =0;
|
|
|
for (String url : urls) {
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(article.getId());
|
|
|
content.setContentData(getBlock(BLOCK_IMAGE,url));
|
|
|
content.setCreateTime(time);
|
|
|
content.setTemplateKey("image");
|
|
|
content.setOrderBy(contentOrder);
|
|
|
contentOrder++;
|
|
|
contentList.add(content);
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(req.getContent())){
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(article.getId());
|
|
|
content.setContentData(getBlock(BLOCK_TEXT, req.getContent()));
|
|
|
content.setCreateTime(time);
|
|
|
content.setTemplateKey("text");
|
|
|
content.setOrderBy(contentOrder);
|
|
|
contentList.add(content);
|
|
|
}
|
|
|
grassArticleBlockDao.insertArticleContents(contentList);
|
|
|
logger.info("timerPublish insert grass article content success, ariticle id is {}, contentList size is {}", article.getId(), contentList.size());
|
|
|
}catch (Exception e){
|
|
|
logger.warn("timerPublish insert article images fail,ariticle id is {}, e is {}",article.getId(), e );
|
|
|
}
|
|
|
|
|
|
try{
|
|
|
if(StringUtils.isNotEmpty( req.getArticleSkns())){
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(sknList)){
|
|
|
grassArticleProductDao.insertArticleSkns(sknList);
|
|
|
}
|
|
|
logger.info("timerPublish insert grass article skns success, ariticle id is {}, sknList size is {}", article.getId(), sknList.size());
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
logger.warn("timerPublish insert article skns fail,ariticle id is {}, e is {}",article.getId(), e );
|
|
|
}
|
|
|
|
|
|
//构建lables 数据
|
|
|
List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(article.getId(), labels,1);
|
|
|
try{
|
|
|
if(CollectionUtils.isNotEmpty(grassArticleLabels)){
|
|
|
for (GrassArticleLabel label : grassArticleLabels) {
|
|
|
label.setCreateTime(time);
|
|
|
}
|
|
|
grassArticleLabelDao.insertArticleLabels(grassArticleLabels);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
logger.warn("timerPublish ,grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e);
|
|
|
}
|
|
|
|
|
|
//定时发布的内容 免审 免推荐 直接进入推荐列表
|
|
|
Integer articleId = article.getId();
|
|
|
GrassArticle grassArticle = new GrassArticle();
|
|
|
grassArticle.setId(articleId);
|
|
|
grassArticle.setAuthStatus(1);
|
|
|
grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
|
|
|
grassArticle.setAuthTime(time);
|
|
|
grassArticle.setCreateTime(time);
|
|
|
grassArticle.setIsRecommend(1);
|
|
|
grassArticle.setRecommendTime(time);
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
|
|
grassArticleLabel.setArticleId(articleId);
|
|
|
grassArticleLabel.setAuthStatus(1);//审核状态
|
|
|
grassArticleLabel.setCreateTime(time);
|
|
|
grassArticleLabelDao.updateByPrimaryKeySelective(grassArticleLabel);
|
|
|
logger.info("timerPublish updateByPrimaryKeySelective success! id={}",articleId);
|
|
|
|
|
|
}
|
|
|
|
|
|
private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){
|
|
|
if(CollectionUtils.isEmpty(articleList)){
|
|
|
return new ArrayList<>();
|
...
|
...
|
@@ -849,10 +987,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
|
}
|
|
|
|
|
|
|
|
|
private void clearArticleListCache(){
|
|
|
private void clearArticleListCache(Integer articleId){
|
|
|
logger.info("clearArticleListCache, type=1001");
|
|
|
GrassCacheReq cacheReq = new GrassCacheReq();
|
|
|
cacheReq.setClearCode(1001);
|
|
|
cacheReq.setElementId(String.valueOf(articleId));
|
|
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
|
|
}
|
|
|
} |
...
|
...
|
|