优化文章模块读取条件
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.param.ArticleParam;
|
||||||
import com.gxwebsoft.cms.service.ArticleCategoryService;
|
import com.gxwebsoft.cms.service.ArticleCategoryService;
|
||||||
import com.gxwebsoft.cms.service.ArticleService;
|
import com.gxwebsoft.cms.service.ArticleService;
|
||||||
|
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||||
import com.gxwebsoft.common.core.web.*;
|
import com.gxwebsoft.common.core.web.*;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -29,6 +30,8 @@ public class ArticleCategoryController extends BaseController {
|
|||||||
private ArticleCategoryService articleCategoryService;
|
private ArticleCategoryService articleCategoryService;
|
||||||
@Resource
|
@Resource
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@ApiOperation("分页查询文章分类表")
|
@ApiOperation("分页查询文章分类表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@@ -41,22 +44,22 @@ public class ArticleCategoryController extends BaseController {
|
|||||||
@ApiOperation("查询全部文章分类表")
|
@ApiOperation("查询全部文章分类表")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public ApiResult<List<ArticleCategory>> list(ArticleCategoryParam param) {
|
public ApiResult<List<ArticleCategory>> list(ArticleCategoryParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
List<ArticleCategory> categoryList = articleCategoryService.listRel(param);
|
List<ArticleCategory> categoryList = articleCategoryService.listRel(param);
|
||||||
// 是否读取新闻列表
|
// 是否读取新闻列表
|
||||||
if (param.getSceneType() != null && param.getSceneType().equals("showArticle")) {
|
if (param.getSceneType() != null && param.getSceneType().equals("showArticle")) {
|
||||||
categoryList.forEach(d->{
|
categoryList.forEach(d->{
|
||||||
final ArticleParam articleParam = new ArticleParam();
|
final ArticleParam articleParam = new ArticleParam();
|
||||||
articleParam.setCategoryId(d.getCategoryId());
|
articleParam.setCategoryId(d.getCategoryId());
|
||||||
articleParam.setDeleted(0);
|
articleParam.setDeleted(0);
|
||||||
articleParam.setLimit(5L);
|
if(param.getLimit() != null){
|
||||||
final PageResult<Article> articlePageResult = articleService.pageRel(articleParam);
|
articleParam.setLimit(param.getLimit());
|
||||||
d.setArticleList(articlePageResult.getList());
|
}
|
||||||
});
|
final PageResult<Article> articlePageResult = articleService.pageRel(articleParam);
|
||||||
}
|
d.setArticleList(articlePageResult.getList());
|
||||||
return success(categoryList);
|
});
|
||||||
// 使用关联查询
|
}
|
||||||
//return success(articleCategoryService.listRel(param));
|
return success(categoryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("根据id查询文章分类表")
|
@ApiOperation("根据id查询文章分类表")
|
||||||
|
|||||||
@@ -34,21 +34,15 @@ public class ArticleController extends BaseController {
|
|||||||
@ApiOperation("分页查询文章记录表")
|
@ApiOperation("分页查询文章记录表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public ApiResult<PageResult<Article>> page(ArticleParam param) {
|
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("查询全部文章记录表")
|
@ApiOperation("查询全部文章记录表")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public ApiResult<List<Article>> list(ArticleParam param) {
|
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查询文章记录表")
|
@ApiOperation("根据id查询文章记录表")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.gxwebsoft.cms.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|||||||
Reference in New Issue
Block a user