Commit 0a52c239 by 段启岩

修复博客博客引用错误

parent 02603811
...@@ -369,8 +369,11 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB ...@@ -369,8 +369,11 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
topicReferenceService.list(topicReferenceQueryWrapper).stream() topicReferenceService.list(topicReferenceQueryWrapper).stream()
.map(TopicReference::getTopicId).collect(Collectors.toList()); .map(TopicReference::getTopicId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(referencedTopicIds)) { if (CollectionUtils.isEmpty(referencedTopicIds)) {
// 减少话题引用测试
topicService.decreaseReferenceCountBatch(referencedTopicIds, 1); topicService.decreaseReferenceCountBatch(referencedTopicIds, 1);
} }
// 删除话题引用
topicReferenceService.remove(topicReferenceQueryWrapper); topicReferenceService.remove(topicReferenceQueryWrapper);
} }
...@@ -384,10 +387,8 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB ...@@ -384,10 +387,8 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
} }
// 批量保存 // 批量保存
topicReferenceService.saveBatch(topicReferenceList); topicReferenceService.saveBatch(topicReferenceList);
// 更新话题引用次数 // 新增话题引用次数
existsTopicIds.forEach(topicId -> { topicService.increaseReferenceCountBatch(existsTopicIds, 1);
topicService.increaseReferenceCount(topicId, 1);
});
} }
} }
...@@ -405,8 +406,10 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB ...@@ -405,8 +406,10 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
blogTagService.list(blogTagQueryWrapper).stream() blogTagService.list(blogTagQueryWrapper).stream()
.map(BlogTag::getTagId).collect(Collectors.toList()); .map(BlogTag::getTagId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(referencedTagIds)) { if (CollectionUtils.isEmpty(referencedTagIds)) {
// 减少标签引用次数
tagService.decreaseReferenceCountBatch(referencedTagIds, 1); tagService.decreaseReferenceCountBatch(referencedTagIds, 1);
} }
// 删除标签引用
blogTagService.remove(blogTagQueryWrapper); blogTagService.remove(blogTagQueryWrapper);
} }
...@@ -417,7 +420,10 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB ...@@ -417,7 +420,10 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
blogTag.setTagId(tagId); blogTag.setTagId(tagId);
blogTagList.add(blogTag); blogTagList.add(blogTag);
} }
// 保存标签引用
blogTagService.saveBatch(blogTagList); blogTagService.saveBatch(blogTagList);
// 删除标签引用次数
tagService.increaseReferenceCountBatch(existsTagIds, 1);
} }
} }
} }
......
...@@ -332,8 +332,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i ...@@ -332,8 +332,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
topicReferenceService.list(topicReferenceQueryWrapper).stream() topicReferenceService.list(topicReferenceQueryWrapper).stream()
.map(TopicReference::getTopicId).collect(Collectors.toList()); .map(TopicReference::getTopicId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(referencedTopicIds)) { if (CollectionUtils.isEmpty(referencedTopicIds)) {
// 减少话题引用数量
topicService.decreaseReferenceCountBatch(referencedTopicIds, 1); topicService.decreaseReferenceCountBatch(referencedTopicIds, 1);
} }
// 删除话题引用
topicReferenceService.remove(topicReferenceQueryWrapper); topicReferenceService.remove(topicReferenceQueryWrapper);
} }
...@@ -349,7 +351,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i ...@@ -349,7 +351,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 保存话题引用 // 保存话题引用
topicReferenceService.saveBatch(topicReferenceList); topicReferenceService.saveBatch(topicReferenceList);
// 更新话题引用次数 // 增加话题引用次数
topicService.increaseReferenceCountBatch(existsTopicIds, 1); topicService.increaseReferenceCountBatch(existsTopicIds, 1);
} }
} }
...@@ -368,8 +370,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i ...@@ -368,8 +370,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
questionTagService.list(questionTagQueryWrapper).stream() questionTagService.list(questionTagQueryWrapper).stream()
.map(QuestionTag::getTagId).collect(Collectors.toList()); .map(QuestionTag::getTagId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(referencedTagIds)) { if (CollectionUtils.isEmpty(referencedTagIds)) {
// 减少标签引用数量
tagService.decreaseReferenceCountBatch(referencedTagIds, 1); tagService.decreaseReferenceCountBatch(referencedTagIds, 1);
} }
// 删除标签引用
questionTagService.remove(questionTagQueryWrapper); questionTagService.remove(questionTagQueryWrapper);
} }
...@@ -381,8 +385,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i ...@@ -381,8 +385,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
questionTag.setTagId(tagId); questionTag.setTagId(tagId);
return questionTag; return questionTag;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 保存标签引用
questionTagService.saveBatch(questionTagList); questionTagService.saveBatch(questionTagList);
// 更新标签引用次数 // 增加标签引用次数
tagService.increaseReferenceCountBatch(existsTagIds, 1); tagService.increaseReferenceCountBatch(existsTagIds, 1);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment