|
@@ -270,40 +270,44 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
communityArticleMapper.insert(communityArticle);
|
|
communityArticleMapper.insert(communityArticle);
|
|
//插入标签日志
|
|
//插入标签日志
|
|
List<String> tags = communityArticle.getTags();
|
|
List<String> tags = communityArticle.getTags();
|
|
- CommunityArticleTag tagLog = null;
|
|
|
|
- for (String tag : tags) {
|
|
|
|
- tagLog = new CommunityArticleTag();
|
|
|
|
- tagLog.setArticleId(communityArticle.getId());
|
|
|
|
- tagLog.setTagId(Long.parseLong(tag));
|
|
|
|
- tagLog.setUpdateBy(userId);
|
|
|
|
- tagLog.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
- tagLog.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
- tagLog.setCreateBy(userId);
|
|
|
|
- articleTagMapper.insert(tagLog);
|
|
|
|
-
|
|
|
|
- //标签热度自增
|
|
|
|
- CommunityTag communityTag = communityTagMapper.selectById(Long.parseLong(tag));
|
|
|
|
- communityTag.setTagHot(Objects.isNull(communityTag.getTagHot()) ? 1 : communityTag.getTagHot() + 1);
|
|
|
|
- communityTag.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
- communityTag.setUpdateBy(userId);
|
|
|
|
- communityTagMapper.updateById(communityTag);
|
|
|
|
|
|
+ if (tags != null && !tags.isEmpty()) {
|
|
|
|
+ CommunityArticleTag tagLog = null;
|
|
|
|
+ for (String tag : tags) {
|
|
|
|
+ tagLog = new CommunityArticleTag();
|
|
|
|
+ tagLog.setArticleId(communityArticle.getId());
|
|
|
|
+ tagLog.setTagId(Long.parseLong(tag));
|
|
|
|
+ tagLog.setUpdateBy(userId);
|
|
|
|
+ tagLog.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ tagLog.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ tagLog.setCreateBy(userId);
|
|
|
|
+ articleTagMapper.insert(tagLog);
|
|
|
|
+
|
|
|
|
+ //标签热度自增
|
|
|
|
+ CommunityTag communityTag = communityTagMapper.selectById(Long.parseLong(tag));
|
|
|
|
+ communityTag.setTagHot(Objects.isNull(communityTag.getTagHot()) ? 1 : communityTag.getTagHot() + 1);
|
|
|
|
+ communityTag.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityTag.setUpdateBy(userId);
|
|
|
|
+ communityTagMapper.updateById(communityTag);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//插入图片日志
|
|
//插入图片日志
|
|
List<String> images = communityArticle.getImages();
|
|
List<String> images = communityArticle.getImages();
|
|
- CommunityArticleImages articleImages = null;
|
|
|
|
- for (String image : images) {
|
|
|
|
- articleImages = new CommunityArticleImages();
|
|
|
|
- articleImages.setArticleId(communityArticle.getId());
|
|
|
|
- articleImages.setImageUrl(image);
|
|
|
|
- articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
- articleImages.setCreateBy(userId);
|
|
|
|
- communityArticleImagesMapper.insert(articleImages);
|
|
|
|
|
|
+ if (images != null && !images.isEmpty()) {
|
|
|
|
+ CommunityArticleImages articleImages = null;
|
|
|
|
+ for (String image : images) {
|
|
|
|
+ articleImages = new CommunityArticleImages();
|
|
|
|
+ articleImages.setArticleId(communityArticle.getId());
|
|
|
|
+ articleImages.setImageUrl(image);
|
|
|
|
+ articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ articleImages.setCreateBy(userId);
|
|
|
|
+ communityArticleImagesMapper.insert(articleImages);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//插入板块
|
|
//插入板块
|
|
List<Long> classIds = communityArticle.getClassIds();
|
|
List<Long> classIds = communityArticle.getClassIds();
|
|
- if (!classIds.isEmpty()) {
|
|
|
|
|
|
+ if (classIds != null && !classIds.isEmpty()) {
|
|
List<CommunityArticleClass> articleClasses = new ArrayList<>();
|
|
List<CommunityArticleClass> articleClasses = new ArrayList<>();
|
|
CommunityArticleClass articleClass = null;
|
|
CommunityArticleClass articleClass = null;
|
|
for (Long classId : classIds) {
|
|
for (Long classId : classIds) {
|
|
@@ -319,17 +323,20 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
|
|
|
//插入合集
|
|
//插入合集
|
|
List<String> collectionIds = communityArticle.getCollectionIds();
|
|
List<String> collectionIds = communityArticle.getCollectionIds();
|
|
- List<CommunityCollectionArticle> collectionArticles = new ArrayList<>();
|
|
|
|
- CommunityCollectionArticle collectionArticle = null;
|
|
|
|
- for (String collectionId : collectionIds) {
|
|
|
|
- collectionArticle = new CommunityCollectionArticle();
|
|
|
|
- collectionArticle.setCollectionId(Long.parseLong(collectionId));
|
|
|
|
- collectionArticle.setArticleId(communityArticle.getId());
|
|
|
|
- collectionArticle.setCreateBy(userId);
|
|
|
|
- collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
- collectionArticles.add(collectionArticle);
|
|
|
|
|
|
+ if (collectionIds != null && !collectionIds.isEmpty()) {
|
|
|
|
+ List<CommunityCollectionArticle> collectionArticles = new ArrayList<>();
|
|
|
|
+ CommunityCollectionArticle collectionArticle = null;
|
|
|
|
+ for (String collectionId : collectionIds) {
|
|
|
|
+ collectionArticle = new CommunityCollectionArticle();
|
|
|
|
+ collectionArticle.setCollectionId(Long.parseLong(collectionId));
|
|
|
|
+ collectionArticle.setArticleId(communityArticle.getId());
|
|
|
|
+ collectionArticle.setCreateBy(userId);
|
|
|
|
+ collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ collectionArticles.add(collectionArticle);
|
|
|
|
+ }
|
|
|
|
+ collectionArticleService.saveBatch(collectionArticles);
|
|
}
|
|
}
|
|
- collectionArticleService.saveBatch(collectionArticles);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|