From f7038dea41c9dac25fabbee402e243b9476fd3ad Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Wed, 13 Mar 2024 20:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E7=AB=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=AF=BB=E5=8F=96=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ArticleCategoryController.java | 35 ++++++++++--------- .../cms/controller/ArticleController.java | 10 ++---- .../java/com/gxwebsoft/cms/entity/Design.java | 2 +- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java index 24d9399..4cebe3e 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.cms.param.ArticleCategoryParam; import com.gxwebsoft.cms.param.ArticleParam; import com.gxwebsoft.cms.service.ArticleCategoryService; import com.gxwebsoft.cms.service.ArticleService; +import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.web.*; import com.gxwebsoft.common.system.entity.User; import io.swagger.annotations.Api; @@ -29,6 +30,8 @@ public class ArticleCategoryController extends BaseController { private ArticleCategoryService articleCategoryService; @Resource private ArticleService articleService; + @Resource + private RedisUtil redisUtil; @ApiOperation("分页查询文章分类表") @GetMapping("/page") @@ -41,22 +44,22 @@ public class ArticleCategoryController extends BaseController { @ApiOperation("查询全部文章分类表") @GetMapping() public ApiResult> list(ArticleCategoryParam param) { - // 使用关联查询 - List categoryList = articleCategoryService.listRel(param); - // 是否读取新闻列表 - if (param.getSceneType() != null && param.getSceneType().equals("showArticle")) { - categoryList.forEach(d->{ - final ArticleParam articleParam = new ArticleParam(); - articleParam.setCategoryId(d.getCategoryId()); - articleParam.setDeleted(0); - articleParam.setLimit(5L); - final PageResult
articlePageResult = articleService.pageRel(articleParam); - d.setArticleList(articlePageResult.getList()); - }); - } - return success(categoryList); - // 使用关联查询 - //return success(articleCategoryService.listRel(param)); + // 使用关联查询 + List categoryList = articleCategoryService.listRel(param); + // 是否读取新闻列表 + if (param.getSceneType() != null && param.getSceneType().equals("showArticle")) { + categoryList.forEach(d->{ + final ArticleParam articleParam = new ArticleParam(); + articleParam.setCategoryId(d.getCategoryId()); + articleParam.setDeleted(0); + if(param.getLimit() != null){ + articleParam.setLimit(param.getLimit()); + } + final PageResult
articlePageResult = articleService.pageRel(articleParam); + d.setArticleList(articlePageResult.getList()); + }); + } + return success(categoryList); } @ApiOperation("根据id查询文章分类表") diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java index 314e8bc..7ecf56b 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java @@ -34,21 +34,15 @@ public class ArticleController extends BaseController { @ApiOperation("分页查询文章记录表") @GetMapping("/page") public ApiResult> page(ArticleParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); - return success(articleService.page(page, page.getWrapper())); // 使用关联查询 - //return success(articleService.pageRel(param)); + return success(articleService.pageRel(param)); } @ApiOperation("查询全部文章记录表") @GetMapping() public ApiResult> list(ArticleParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); - return success(articleService.list(page.getOrderWrapper())); // 使用关联查询 - //return success(articleService.listRel(param)); + return success(articleService.listRel(param)); } @ApiOperation("根据id查询文章记录表") diff --git a/src/main/java/com/gxwebsoft/cms/entity/Design.java b/src/main/java/com/gxwebsoft/cms/entity/Design.java index 5b79e10..0990824 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Design.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Design.java @@ -3,7 +3,7 @@ package com.gxwebsoft.cms.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data;