优化文章模块读取条件
This commit is contained in:
@@ -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<ArticleCategory>> list(ArticleCategoryParam param) {
|
||||
// 使用关联查询
|
||||
List<ArticleCategory> 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<Article> articlePageResult = articleService.pageRel(articleParam);
|
||||
d.setArticleList(articlePageResult.getList());
|
||||
});
|
||||
}
|
||||
return success(categoryList);
|
||||
// 使用关联查询
|
||||
//return success(articleCategoryService.listRel(param));
|
||||
// 使用关联查询
|
||||
List<ArticleCategory> 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<Article> articlePageResult = articleService.pageRel(articleParam);
|
||||
d.setArticleList(articlePageResult.getList());
|
||||
});
|
||||
}
|
||||
return success(categoryList);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询文章分类表")
|
||||
|
||||
@@ -34,21 +34,15 @@ public class ArticleController extends BaseController {
|
||||
@ApiOperation("分页查询文章记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Article>> page(ArticleParam param) {
|
||||
PageParam<Article, ArticleParam> 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<Article>> list(ArticleParam param) {
|
||||
PageParam<Article, ArticleParam> 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查询文章记录表")
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user