zero 1 周之前
父节点
当前提交
6b54c1347b
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/main/java/com/cslg/ppa/service/ArticleInfoService.java

+ 4 - 4
src/main/java/com/cslg/ppa/service/ArticleInfoService.java

@@ -157,13 +157,13 @@ public class ArticleInfoService extends ServiceImpl<ArticleInfoMapper, ArticleIn
         articleInfo.setDigest(infoDTO.getDigest());
         articleInfo.updateById();
 
-        // 先删除原有的关联关系
-        articleCategoryRelationService.remove(new LambdaQueryWrapper<ArticleCategoryRelation>()
-                .eq(ArticleCategoryRelation::getArticleId, articleId));
-
         // 再添加新的关联关系
         List<Integer> categoryIds = infoDTO.getCategoryIds();
         if (!CollectionUtils.isEmpty(categoryIds)) {
+            // 先删除原有的关联关系
+            articleCategoryRelationService.remove(new LambdaQueryWrapper<ArticleCategoryRelation>()
+                    .eq(ArticleCategoryRelation::getArticleId, articleId));
+
             for (Integer categoryId : categoryIds) {
                 ArticleCategoryRelation relation = new ArticleCategoryRelation();
                 relation.setArticleId(articleId);