1,cms首页接口

main
zhc077 1 year ago
parent 8c98faeaa9
commit ac1f03862f
  1. 2
      jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 70
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsHomePageController.java

@ -99,6 +99,8 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码 filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除 filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
//CMS门户
filterChainDefinitionMap.put("/cms/front/**","anon");
filterChainDefinitionMap.put("/", "anon"); filterChainDefinitionMap.put("/", "anon");
filterChainDefinitionMap.put("/doc.html", "anon"); filterChainDefinitionMap.put("/doc.html", "anon");

@ -0,0 +1,70 @@
package org.jeecg.modules.demo.cms.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.demo.cms.entity.CmsArticle;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import org.jeecg.modules.demo.cms.service.ICmsArticleService;
import org.jeecg.modules.demo.cms.service.ICmsColumnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Api(tags = "cms首页")
@RestController
@RequestMapping("/cms/front")
@Slf4j
public class CmsHomePageController /*extends JeecgController<CmsColumn, ICmsColumnService>*/ {
@Autowired
private ICmsColumnService cmsColumnService;
@Autowired
private ICmsArticleService cmsArticleService;
@ApiOperation(value = "文章栏目-列表", notes = "文章栏目-列表")
@GetMapping(value = "/getColumnList")
public Result<?> getColumnList(HttpServletRequest req) {
List<CmsColumn> list = cmsColumnService.list(new LambdaQueryWrapper<CmsColumn>()
.eq(CmsColumn::getIsShow, "1")
.orderByAsc(CmsColumn::getSort));
return Result.OK(list);
}
@ApiOperation(value = "通过栏目类型获取文章列表", notes = "通过栏目类型获取文章列表")
@GetMapping(value = "/getArticleListByColumn")
public Result<?> getArticleListByColumn(CmsArticle cmsArticle,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap());
queryWrapper.eq("status", "1");
queryWrapper.eq("column_id", cmsArticle.getColumnId());
queryWrapper.last("order by publish_time desc");
Page<CmsArticle> page = new Page<CmsArticle>(pageNo, pageSize);
IPage<CmsArticle> pageList = cmsArticleService.page(page, queryWrapper);
return Result.OK(pageList);
}
@ApiOperation(value = "通过文单标题查询", notes = "通过文单标题查询")
@GetMapping(value = "/getByArticleTitle")
public Result<?> getByArticleTitle(CmsArticle cmsArticle, HttpServletRequest req) {
List<CmsArticle> list = cmsArticleService.list(new LambdaQueryWrapper<CmsArticle>()
.eq(CmsArticle::getStatus, "1")
.eq(CmsArticle::getTitle, cmsArticle.getTitle())
.orderByDesc(CmsArticle::getPublishTime));
return Result.OK(list);
}
}
Loading…
Cancel
Save