Helius
2021-01-12 a88cf964159303c208d8a3a9d0b8dadef7b1388a
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,42 @@
@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));
    }
    @ApiOperation(value = "获取文章详情页", notes = "获取文章详情页")
    @GetMapping(value = "/findArticleDetail/{id}")
    public AjaxResult findArticleDetail(@PathVariable("id") Long id) {
        Article article = articleService.findById(id);
        AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功");
        ajaxResult.putInMap("article", article);
        return ajaxResult;
    }
}