|
@@ -346,7 +346,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
@@ -346,7 +346,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
346
|
}
|
346
|
}
|
347
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
347
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
348
|
//推荐和置顶操作,清前台缓存
|
348
|
//推荐和置顶操作,清前台缓存
|
349
|
- clearArticleListCache();
|
349
|
+ clearArticleListCache(req.getArticleId());
|
350
|
}
|
350
|
}
|
351
|
//编辑文章 没地方用到
|
351
|
//编辑文章 没地方用到
|
352
|
if(type == 1){
|
352
|
if(type == 1){
|
|
@@ -451,6 +451,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
@@ -451,6 +451,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
451
|
grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
|
451
|
grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
|
452
|
grassArticle.setAuthTime(time);
|
452
|
grassArticle.setAuthTime(time);
|
453
|
grassArticle.setCreateTime(time);
|
453
|
grassArticle.setCreateTime(time);
|
|
|
454
|
+ grassArticle.setIsRecommend(1);
|
|
|
455
|
+ grassArticle.setRecommendTime(time);
|
454
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
456
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
455
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
457
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
456
|
grassArticleLabel.setArticleId(articleId);
|
458
|
grassArticleLabel.setArticleId(articleId);
|
|
@@ -469,6 +471,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
@@ -469,6 +471,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
469
|
grassArticle.setAuthorizeAccount("");
|
471
|
grassArticle.setAuthorizeAccount("");
|
470
|
grassArticle.setAuthTime(0L);
|
472
|
grassArticle.setAuthTime(0L);
|
471
|
grassArticle.setCreateTime(0L);
|
473
|
grassArticle.setCreateTime(0L);
|
|
|
474
|
+ grassArticle.setIsRecommend(0);
|
|
|
475
|
+ grassArticle.setRecommendTime(0L);
|
472
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
476
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
473
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
477
|
GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
474
|
grassArticleLabel.setArticleId(articleId);
|
478
|
grassArticleLabel.setArticleId(articleId);
|
|
@@ -684,6 +688,140 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
@@ -684,6 +688,140 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
684
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
688
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
685
|
}
|
689
|
}
|
686
|
|
690
|
|
|
|
691
|
+ @Override
|
|
|
692
|
+ public void timerPublish(GrassArticleReq req) throws PlatformException {
|
|
|
693
|
+ logger.info("enter timerPublish, req is {}", req);
|
|
|
694
|
+ publishCheck(req);
|
|
|
695
|
+
|
|
|
696
|
+ String publishTime = req.getPublishTime();
|
|
|
697
|
+ if(StringUtils.isEmpty(publishTime)){
|
|
|
698
|
+ throw new PlatformException("publishTime is null", 402);
|
|
|
699
|
+ }
|
|
|
700
|
+ long time = Long.valueOf(publishTime)+ new Random().nextInt(999);
|
|
|
701
|
+
|
|
|
702
|
+ List<Integer> labels = Lists.newArrayList();
|
|
|
703
|
+ String[] urls = req.getArticleImages().split(",");
|
|
|
704
|
+ String[] skns = null;
|
|
|
705
|
+ if(StringUtils.isNotEmpty(req.getArticleSkns())){
|
|
|
706
|
+ skns = req.getArticleSkns().split(",");
|
|
|
707
|
+ if(skns.length > 5){
|
|
|
708
|
+ logger.info("timerPublish , article products more than most publish number");
|
|
|
709
|
+ throw new PlatformException("publish products most number is 5 ", 405);
|
|
|
710
|
+ }
|
|
|
711
|
+ }
|
|
|
712
|
+ if(urls.length > 9){
|
|
|
713
|
+ logger.info("timerPublish , article images more than most publish number");
|
|
|
714
|
+ throw new PlatformException("publish images most number is 9 ", 405);
|
|
|
715
|
+ }
|
|
|
716
|
+ if(StringUtils.isNotEmpty(req.getLabelIds())){
|
|
|
717
|
+ labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
718
|
+ if(labels.size() > 5){
|
|
|
719
|
+ logger.info("timerPublish , article labels more than most publish number");
|
|
|
720
|
+ throw new PlatformException("publish labels most number is 5 ", 405);
|
|
|
721
|
+ }
|
|
|
722
|
+ }
|
|
|
723
|
+
|
|
|
724
|
+ GrassArticle article = new GrassArticle();
|
|
|
725
|
+ article.setAuthorUid(req.getAuthorUid());
|
|
|
726
|
+ article.setCreateTime(time);
|
|
|
727
|
+ article.setAuthStatus(1);
|
|
|
728
|
+ article.setAuthTime(time);
|
|
|
729
|
+ try{
|
|
|
730
|
+ grassArticleDao.insertArticleSeletive(article);
|
|
|
731
|
+ logger.info("insert grass article success, uid is {}, ariticle id is {}", article.getAuthorUid(), article.getId());
|
|
|
732
|
+ }catch (Exception e){
|
|
|
733
|
+ logger.warn("insert grass article fail, uid is {}, e is {}",req.getAuthorUid(), e );
|
|
|
734
|
+ throw new PlatformException("timerPublish article failed", 402);
|
|
|
735
|
+ }
|
|
|
736
|
+
|
|
|
737
|
+ try{
|
|
|
738
|
+ List<GrassArticleBlock> contentList = Lists.newArrayList();
|
|
|
739
|
+ int contentOrder =0;
|
|
|
740
|
+ for (String url : urls) {
|
|
|
741
|
+ GrassArticleBlock content = new GrassArticleBlock();
|
|
|
742
|
+ content.setArticleId(article.getId());
|
|
|
743
|
+ content.setContentData(getBlock(BLOCK_IMAGE,url));
|
|
|
744
|
+ content.setCreateTime(time);
|
|
|
745
|
+ content.setTemplateKey("image");
|
|
|
746
|
+ content.setOrderBy(contentOrder);
|
|
|
747
|
+ contentOrder++;
|
|
|
748
|
+ contentList.add(content);
|
|
|
749
|
+ }
|
|
|
750
|
+ if(StringUtils.isNotEmpty(req.getContent())){
|
|
|
751
|
+ GrassArticleBlock content = new GrassArticleBlock();
|
|
|
752
|
+ content.setArticleId(article.getId());
|
|
|
753
|
+ content.setContentData(getBlock(BLOCK_TEXT, req.getContent()));
|
|
|
754
|
+ content.setCreateTime(time);
|
|
|
755
|
+ content.setTemplateKey("text");
|
|
|
756
|
+ content.setOrderBy(contentOrder);
|
|
|
757
|
+ contentList.add(content);
|
|
|
758
|
+ }
|
|
|
759
|
+ grassArticleBlockDao.insertArticleContents(contentList);
|
|
|
760
|
+ logger.info("timerPublish insert grass article content success, ariticle id is {}, contentList size is {}", article.getId(), contentList.size());
|
|
|
761
|
+ }catch (Exception e){
|
|
|
762
|
+ logger.warn("timerPublish insert article images fail,ariticle id is {}, e is {}",article.getId(), e );
|
|
|
763
|
+ }
|
|
|
764
|
+
|
|
|
765
|
+ try{
|
|
|
766
|
+ if(StringUtils.isNotEmpty( req.getArticleSkns())){
|
|
|
767
|
+ int orderby = 0;
|
|
|
768
|
+ List<GrassArticleProduct> sknList = Lists.newArrayList();
|
|
|
769
|
+ if(skns != null){
|
|
|
770
|
+ Integer sknType = Optional.ofNullable(req.getSknType()).orElse(1);
|
|
|
771
|
+ for (String skn: skns) {
|
|
|
772
|
+ GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
|
|
|
773
|
+ grassArticleSkn.setArticleId(article.getId());
|
|
|
774
|
+ grassArticleSkn.setProductSkn(Integer.valueOf(skn));
|
|
|
775
|
+ grassArticleSkn.setCreateTime(time);
|
|
|
776
|
+ grassArticleSkn.setOrderBy(orderby);
|
|
|
777
|
+ grassArticleSkn.setProductSource(sknType);
|
|
|
778
|
+ orderby++;
|
|
|
779
|
+ sknList.add(grassArticleSkn);
|
|
|
780
|
+ }
|
|
|
781
|
+ }
|
|
|
782
|
+
|
|
|
783
|
+ if(CollectionUtils.isNotEmpty(sknList)){
|
|
|
784
|
+ grassArticleProductDao.insertArticleSkns(sknList);
|
|
|
785
|
+ }
|
|
|
786
|
+ logger.info("timerPublish insert grass article skns success, ariticle id is {}, sknList size is {}", article.getId(), sknList.size());
|
|
|
787
|
+ }
|
|
|
788
|
+ }catch (Exception e){
|
|
|
789
|
+ logger.warn("timerPublish insert article skns fail,ariticle id is {}, e is {}",article.getId(), e );
|
|
|
790
|
+ }
|
|
|
791
|
+
|
|
|
792
|
+ //构建lables 数据
|
|
|
793
|
+ List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(article.getId(), labels,1);
|
|
|
794
|
+ try{
|
|
|
795
|
+ if(CollectionUtils.isNotEmpty(grassArticleLabels)){
|
|
|
796
|
+ for (GrassArticleLabel label : grassArticleLabels) {
|
|
|
797
|
+ label.setCreateTime(time);
|
|
|
798
|
+ }
|
|
|
799
|
+ grassArticleLabelDao.insertArticleLabels(grassArticleLabels);
|
|
|
800
|
+ }
|
|
|
801
|
+ }catch (Exception e){
|
|
|
802
|
+ logger.warn("timerPublish ,grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e);
|
|
|
803
|
+ }
|
|
|
804
|
+
|
|
|
805
|
+ //定时发布的内容 免审 免推荐 直接进入推荐列表
|
|
|
806
|
+ Integer articleId = article.getId();
|
|
|
807
|
+ GrassArticle grassArticle = new GrassArticle();
|
|
|
808
|
+ grassArticle.setId(articleId);
|
|
|
809
|
+ grassArticle.setAuthStatus(1);
|
|
|
810
|
+ grassArticle.setAuthorizeAccount(req.getAuthorizeAccount());
|
|
|
811
|
+ grassArticle.setAuthTime(time);
|
|
|
812
|
+ grassArticle.setCreateTime(time);
|
|
|
813
|
+ grassArticle.setIsRecommend(1);
|
|
|
814
|
+ grassArticle.setRecommendTime(time);
|
|
|
815
|
+ grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
816
|
+ GrassArticleLabel grassArticleLabel = new GrassArticleLabel();
|
|
|
817
|
+ grassArticleLabel.setArticleId(articleId);
|
|
|
818
|
+ grassArticleLabel.setAuthStatus(1);//审核状态
|
|
|
819
|
+ grassArticleLabel.setCreateTime(time);
|
|
|
820
|
+ grassArticleLabelDao.updateByPrimaryKeySelective(grassArticleLabel);
|
|
|
821
|
+ logger.info("timerPublish updateByPrimaryKeySelective success! id={}",articleId);
|
|
|
822
|
+
|
|
|
823
|
+ }
|
|
|
824
|
+
|
687
|
private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){
|
825
|
private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){
|
688
|
if(CollectionUtils.isEmpty(articleList)){
|
826
|
if(CollectionUtils.isEmpty(articleList)){
|
689
|
return new ArrayList<>();
|
827
|
return new ArrayList<>();
|
|
@@ -849,10 +987,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
|
@@ -849,10 +987,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ |
849
|
}
|
987
|
}
|
850
|
|
988
|
|
851
|
|
989
|
|
852
|
- private void clearArticleListCache(){
|
990
|
+ private void clearArticleListCache(Integer articleId){
|
853
|
logger.info("clearArticleListCache, type=1001");
|
991
|
logger.info("clearArticleListCache, type=1001");
|
854
|
GrassCacheReq cacheReq = new GrassCacheReq();
|
992
|
GrassCacheReq cacheReq = new GrassCacheReq();
|
855
|
cacheReq.setClearCode(1001);
|
993
|
cacheReq.setClearCode(1001);
|
|
|
994
|
+ cacheReq.setElementId(String.valueOf(articleId));
|
856
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
995
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
857
|
}
|
996
|
}
|
858
|
} |
997
|
} |