Selaa lähdekoodia

删除分类后,草稿箱、文章审核的文章分类信息显示不正确

danch 3 kuukautta sitten
vanhempi
commit
8758bb7657

+ 13 - 4
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/controller/ArticleController.java

@@ -12,6 +12,8 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.aspect.annotation.PermissionData;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.kms.bas.entity.Category;
+import org.jeecg.modules.kms.bas.service.ICategoryService;
 import org.jeecg.modules.kms.knowledge.entity.Article;
 import org.jeecg.modules.kms.knowledge.param.FilterParam;
 import org.jeecg.modules.kms.knowledge.service.IArticleCategoryRService;
@@ -33,10 +35,10 @@ import java.util.stream.Collectors;
 /**
  * @Description: 知识管理-文章
  * @Author: jeecg-boot
- * @Date:   2023-12-08
+ * @Date: 2023-12-08
  * @Version: V1.0
  */
-@Api(tags="知识管理-文章")
+@Api(tags = "知识管理-文章")
 @RestController
 @RequestMapping("/kms/article")
 @Slf4j
@@ -49,6 +51,8 @@ public class ArticleController extends JeecgController<Article, IArticleService>
     private IArticleCategoryRService articleCategoryRService;
     @Resource
     private IArticleTagRService articleTagRService;
+    @Resource
+    private ICategoryService categoryService;
 
     /**
      * 分页列表查询
@@ -69,12 +73,17 @@ public class ArticleController extends JeecgController<Article, IArticleService>
         QueryWrapper<Article> queryWrapper = QueryGenerator.initQueryWrapper(article, req.getParameterMap());
         Page<Article> page = new Page<Article>(pageNo, pageSize);
         IPage<Article> pageList = articleService.page(page, queryWrapper);
+        // 获取CategoryId,如果CategoryId删除就获取他的父id以此类推
+        for (Article articleFor : pageList.getRecords()) {
+            List<Category> categories = categoryService.queryParentNodeById(articleFor.getCategoryId());
+            articleFor.setCategoryId(categories.get(0).getId());
+        }
         return Result.OK(pageList);
     }
 
     @ApiOperation(value = "知识管理-文章-分页列表查询", notes = "知识管理-文章-分页列表查询")
     @PostMapping(value = "/queryPageListByFilters")
-	@PermissionData(pageComponent="kms/knowledge/article/ArticleList")
+    @PermissionData(pageComponent = "kms/knowledge/article/ArticleList")
     public Result<IPage<Article>> queryPageListByFilters(@RequestBody FilterParam param) {
 
         return Result.OK(articleService.queryPageListByFilters(param));
@@ -148,7 +157,7 @@ public class ArticleController extends JeecgController<Article, IArticleService>
         this.articleService.auditBatchByIds(idList);
         if (idList.size() == 1) {
             return Result.OK("审核成功!");
-        }else {
+        } else {
             return Result.OK("批量审核成功!");
         }
     }