From 109fb70d4132b440a03299ce6520861280a7bf15 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 05 Jan 2021 11:19:40 +0800
Subject: [PATCH] add knowledge interface

---
 zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java              |   26 +++++++++++++
 zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java |    7 ++-
 zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml                    |   13 ++++++
 zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java                 |    4 +
 zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java         |    1 
 zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java       |   32 +++++++++++++--
 6 files changed, 74 insertions(+), 9 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
index 4fd7d76..ca4fc07 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
+++ b/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));
     }
 
 }
diff --git a/zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java b/zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java
new file mode 100644
index 0000000..fa97fee
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/app/dto/ArticleListDto.java
@@ -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;
+    }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java
index 681ed4e..1cb6338 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/dao/ArticleDao.java
+++ b/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);
+
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java b/zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java
index dceb4ad..af74da5 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/ArticleService.java
+++ b/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);
    	
 
   
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java
index 2749a58..f42702b 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ArticleServiceImpl.java
+++ b/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);
+	}
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml
index 40be119..d7b9b0c 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleDao.xml
+++ b/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>
\ No newline at end of file

--
Gitblit v1.9.1