...
|
...
|
@@ -521,9 +521,112 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
//推荐和置顶操作,清前台缓存
|
|
|
clearArticleListCache(req.getArticleId());
|
|
|
}
|
|
|
//编辑文章 没地方用到
|
|
|
//编辑文章
|
|
|
if (type == 1) {
|
|
|
publishCheck(req);
|
|
|
|
|
|
//修改文章内容
|
|
|
Integer articleId = req.getArticleId();
|
|
|
if (articleId == null) {
|
|
|
throw new PlatformException("articleId is null", 402);
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
logger.info("updateArticleDraft , article products more than most publish number");
|
|
|
throw new PlatformException("publish products most number is 10 ", 405);
|
|
|
}
|
|
|
}
|
|
|
if (urls.length > 9) {
|
|
|
logger.info("updateArticleDraft , 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("updateArticleDraft , article labels more than most publish number");
|
|
|
throw new PlatformException("publish labels most number is 5 ", 405);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//修改文章主体内容
|
|
|
long time = 0L;
|
|
|
Integer sort = Optional.ofNullable(req.getSort()).orElse(1);
|
|
|
GrassArticle grassArticle = new GrassArticle();
|
|
|
grassArticle.setId(articleId);
|
|
|
grassArticle.setAuthorUid(req.getAuthorUid());
|
|
|
grassArticle.setUpdateTime(System.currentTimeMillis());
|
|
|
grassArticle.setArticleTitle(req.getTitle());
|
|
|
grassArticle.setArticleSubtitle(req.getSubtitle());
|
|
|
grassArticle.setSort(sort);
|
|
|
grassArticle.setCopyright(req.getCopyright());
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
|
|
|
//文章内容
|
|
|
grassArticleBlockDao.deleteByArticleId(articleId);
|
|
|
|
|
|
//新增
|
|
|
List<GrassArticleBlock> addList = buildArticleBlock(urls, articleId, req);
|
|
|
if (CollectionUtils.isNotEmpty(addList)) {
|
|
|
grassArticleBlockDao.insertArticleContents(addList);
|
|
|
updateArticleImageSize(articleId);
|
|
|
}
|
|
|
|
|
|
//商品
|
|
|
grassArticleProductDao.deleteByArticleId(articleId);
|
|
|
//新增
|
|
|
List<GrassArticleProduct> addSknList = Lists.newArrayList();
|
|
|
int orderBy = 0;
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
//构建lables 数据
|
|
|
grassArticleLabelDao.deleteByArticleId(articleId);
|
|
|
List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(articleId, labels, req.getAuthStatus());
|
|
|
try {
|
|
|
if (CollectionUtils.isNotEmpty(grassArticleLabels) && 3 != req.getSort()) {
|
|
|
grassArticleLabelDao.insertArticleLabels(grassArticleLabels);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("updateArticle grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e);
|
|
|
}
|
|
|
|
|
|
grassArticleTopicDao.deleteByArticleId(articleId);
|
|
|
try {
|
|
|
Integer topicId = req.getTopicId();
|
|
|
if (null != topicId && 3 != sort) {
|
|
|
GrassArticleTopic grassArticleTopic = new GrassArticleTopic();
|
|
|
grassArticleTopic.setTopicId(topicId);
|
|
|
grassArticleTopic.setArticleId(articleId);
|
|
|
grassArticleTopic.setCreateTime(time);
|
|
|
grassArticleTopicDao.insertArticleTopic(grassArticleTopic);
|
|
|
//后期增加(清理话题缓存)
|
|
|
GrassCacheReq cacheReq = new GrassCacheReq();
|
|
|
cacheReq.setClearCode(1005);
|
|
|
cacheReq.setTopicId(topicId);
|
|
|
logger.info("updateArticle clear topicCache topicId={}", topicId);
|
|
|
grassRefreshCacheService.refreshGrassCache(cacheReq);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("publishArticle ,grassArticleTopicDao insertArticleTopic error, uid is {}, e is {}", req.getAuthorUid(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//审核 通过--不通过
|
...
|
...
|
@@ -796,7 +899,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
@Database(ForceMaster = true)
|
|
|
public void updateArticleDraft(GrassArticleReq req) throws PlatformException {
|
|
|
publishCheck(req);
|
|
|
// 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布
|
|
|
// 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布 4 文章已发布二次编辑再次发布
|
|
|
Integer type = req.getDraftType();
|
|
|
|
|
|
//修改文章内容
|
...
|
...
|
|