jyy
2021-01-26 2c25c956ee0dc781500c70c7479c36f8b58f3445
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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.action.util.QueryUtil;
import com.matrix.system.hive.bean.Article;
import com.matrix.system.hive.bean.ArticleType;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.dao.ArticleDao;
import com.matrix.system.hive.dao.SysShopInfoDao;
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.*;
 
/**
 * @author wzy
 * @date 2020-12-27
 **/
@Api(value = "ApiKnowledgeAction", tags = "知识库接口类")
@RestController
@RequestMapping(value = "/api/know")
public class ApiKnowledgeAction extends BaseController {
 
    @Autowired
    private ArticleTypeService articleTypeService;
 
 
    @Autowired
    private ArticleService articleService;
 
    @ApiOperation(value = "获取知识库分类", notes = "获取知识库分类")
    @GetMapping(value = "/findKnowledgeType")
    public AjaxResult findKnowledgeType() {
        ArticleType type = new ArticleType();
        type.setCompanyId(getMe().getCompanyId());
        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();
        QueryUtil.setQueryLimitCom(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;
    }
 
}