zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml | ●●●●● patch | view | raw | blame | history |
zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
@@ -1,13 +1,17 @@ package com.matrix.system.app.action; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.app.dto.ArticleListDto; import com.matrix.system.hive.action.BaseController; import com.matrix.system.hive.bean.Article; import com.matrix.system.hive.bean.ArticleType; import com.matrix.system.hive.service.ArticleService; import com.matrix.system.hive.service.ArticleTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.RestController; import org.springframework.web.bind.annotation.*; /** * @author wzy @@ -16,15 +20,33 @@ @Api(value = "ApiKnowledgeAction", tags = "知识库接口类") @RestController @RequestMapping(value = "/api/know") public class ApiKnowledgeAction { public class ApiKnowledgeAction extends BaseController { @Autowired private ArticleTypeService articleTypeService; @Autowired private ArticleService articleService; @ApiOperation(value = "获取知识库分类", notes = "获取知识库分类") @GetMapping(value = "/findKnowledgeType") public AjaxResult findKnowledgeType() { return null; ArticleType type = new ArticleType(); type.setShopId(getMe().getShopId()); type.setParentId(0L); return AjaxResult.buildSuccessInstance(articleTypeService.findByModel(type)); } @ApiOperation(value = "根据分类获取文章列表", notes = "根据分类获取文章列表") @PostMapping(value = "/findArticleList") public AjaxResult findArticleList(@RequestBody ArticleListDto articleListDto) { PaginationVO pageVo = new PaginationVO(); pageVo.setOffset((articleListDto.getPageNum() - 1) * articleListDto.getPageSize()); pageVo.setLimit(articleListDto.getPageSize()); Article article = new Article(); article.setTypeId(articleListDto.getTypeId()); return AjaxResult.buildSuccessInstance(articleService.findApiArticleListInPage(article, pageVo)); } } zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java
New file @@ -0,0 +1,26 @@ package com.matrix.system.app.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotNull; /** * @author wzy * @date 2021-01-05 **/ @ApiModel(value = "ArticleListDto", description = "文章列表接收参数类") public class ArticleListDto extends BasePageDto { @NotNull @ApiModelProperty(value = "分类ID") private Long typeId; public Long getTypeId() { return typeId; } public void setTypeId(Long typeId) { this.typeId = typeId; } } zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java
@@ -31,5 +31,7 @@ public int selectTotalRecord(@Param("record") Article article); public Article selectById(Long id); public List<Article> selectApiArticleListInPage(@Param("record") Article article, @Param("pageVo") PaginationVO pageVo); } zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java
@@ -72,6 +72,7 @@ */ public Article findById(Long id); public List<Article> findApiArticleListInPage(Article article, PaginationVO pageVo); zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java
@@ -117,7 +117,8 @@ } @Override public List<Article> findApiArticleListInPage(Article article, PaginationVO pageVo) { return articleDao.selectApiArticleListInPage(article, pageVo); } } zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml
@@ -437,4 +437,17 @@ </if> order by type_id,sort,createtiem desc </select> <select id="selectApiArticleListInPage" resultMap="ArticleMap"> select * from article a inner join article_type b on a.type_id=b.id and find_in_set(#{record.typeId}, b.parent_ids) order by a.createtiem desc <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> <if test="pageVo.offset >=0 and pageVo.limit >0"> limit #{pageVo.offset},#{pageVo.limit} </if> </if> </select> </mapper>