|
@@ -17,6 +17,8 @@ import org.jeecg.modules.kms.knowledge.param.FilterParam;
|
|
|
import org.jeecg.modules.kms.knowledge.service.IArticleCategoryRService;
|
|
|
import org.jeecg.modules.kms.comment.service.IArticleCommentRService;
|
|
|
import org.jeecg.modules.kms.knowledge.service.IArticleService;
|
|
|
+import org.jeecg.modules.kms.tag.entity.ArticleTagR;
|
|
|
+import org.jeecg.modules.kms.tag.service.IArticleTagRService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -25,6 +27,8 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 知识管理-文章
|
|
@@ -37,132 +41,143 @@ import java.util.Arrays;
|
|
|
@RequestMapping("/kms/article")
|
|
|
@Slf4j
|
|
|
public class ArticleController extends JeecgController<Article, IArticleService> {
|
|
|
- @Autowired
|
|
|
- private IArticleService articleService;
|
|
|
- @Resource
|
|
|
- private IArticleCommentRService articleCommentRService;
|
|
|
- @Resource
|
|
|
- private IArticleCategoryRService articleCategoryRService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页列表查询
|
|
|
- *
|
|
|
- * @param article
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "知识管理-文章-分页列表查询")
|
|
|
- @ApiOperation(value="知识管理-文章-分页列表查询", notes="知识管理-文章-分页列表查询")
|
|
|
- @GetMapping(value = "/list")
|
|
|
- public Result<IPage<Article>> queryPageList(Article article,
|
|
|
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
- HttpServletRequest req) {
|
|
|
- QueryWrapper<Article> queryWrapper = QueryGenerator.initQueryWrapper(article, req.getParameterMap());
|
|
|
- Page<Article> page = new Page<Article>(pageNo, pageSize);
|
|
|
- IPage<Article> pageList = articleService.page(page, queryWrapper);
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
- @ApiOperation(value="知识管理-文章-分页列表查询", notes="知识管理-文章-分页列表查询")
|
|
|
- @PostMapping(value = "/queryPageListByFilters")
|
|
|
- @PermissionData(pageComponent="kms/knowledge/article/ArticleList")
|
|
|
- public Result<IPage<Article>> queryPageListByFilters(@RequestBody FilterParam param) {
|
|
|
+ @Autowired
|
|
|
+ private IArticleService articleService;
|
|
|
+ @Resource
|
|
|
+ private IArticleCommentRService articleCommentRService;
|
|
|
+ @Resource
|
|
|
+ private IArticleCategoryRService articleCategoryRService;
|
|
|
+ @Resource
|
|
|
+ private IArticleTagRService articleTagRService;
|
|
|
|
|
|
- return Result.OK(articleService.queryPageListByFilters(param));
|
|
|
- }
|
|
|
- /**
|
|
|
- * 添加
|
|
|
- *
|
|
|
- * @param article
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "知识管理-文章-添加")
|
|
|
- @ApiOperation(value="知识管理-文章-添加", notes="知识管理-文章-添加")
|
|
|
- @RequiresPermissions("kms:kms_knowledge_article:add")
|
|
|
- @PostMapping(value = "/add")
|
|
|
- public Result<Article> add(@RequestBody Article article) {
|
|
|
- return Result.OK(articleService.addArticle(article));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑
|
|
|
- *
|
|
|
- * @param article
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "知识管理-文章-编辑")
|
|
|
- @ApiOperation(value="知识管理-文章-编辑", notes="知识管理-文章-编辑")
|
|
|
- @RequiresPermissions("kms:kms_knowledge_article:edit")
|
|
|
- @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
- public Result<String> edit(@RequestBody Article article) {
|
|
|
- articleService.updateArticle(article);
|
|
|
- return Result.OK("编辑成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id删除
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "知识管理-文章-通过id删除")
|
|
|
- @ApiOperation(value="知识管理-文章-通过id删除", notes="知识管理-文章-通过id删除")
|
|
|
- @RequiresPermissions("kms:kms_knowledge_article:delete")
|
|
|
- @DeleteMapping(value = "/delete")
|
|
|
- public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
- articleService.removeById(id);
|
|
|
- return Result.OK("删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "知识管理-文章-批量删除")
|
|
|
- @ApiOperation(value="知识管理-文章-批量删除", notes="知识管理-文章-批量删除")
|
|
|
- @RequiresPermissions("kms:kms_knowledge_article:deleteBatch")
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
- this.articleService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param article
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "知识管理-文章-分页列表查询")
|
|
|
+ @ApiOperation(value = "知识管理-文章-分页列表查询", notes = "知识管理-文章-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<IPage<Article>> queryPageList(Article article,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<Article> queryWrapper = QueryGenerator.initQueryWrapper(article, req.getParameterMap());
|
|
|
+ Page<Article> page = new Page<Article>(pageNo, pageSize);
|
|
|
+ IPage<Article> pageList = articleService.page(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "知识管理-文章-分页列表查询", notes = "知识管理-文章-分页列表查询")
|
|
|
+ @PostMapping(value = "/queryPageListByFilters")
|
|
|
+ @PermissionData(pageComponent="kms/knowledge/article/ArticleList")
|
|
|
+ public Result<IPage<Article>> queryPageListByFilters(@RequestBody FilterParam param) {
|
|
|
+
|
|
|
+ return Result.OK(articleService.queryPageListByFilters(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param article
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "知识管理-文章-添加")
|
|
|
+ @ApiOperation(value = "知识管理-文章-添加", notes = "知识管理-文章-添加")
|
|
|
+ @RequiresPermissions("kms:kms_knowledge_article:add")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<Article> add(@RequestBody Article article) {
|
|
|
+ return Result.OK(articleService.addArticle(article));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param article
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "知识管理-文章-编辑")
|
|
|
+ @ApiOperation(value = "知识管理-文章-编辑", notes = "知识管理-文章-编辑")
|
|
|
+ @RequiresPermissions("kms:kms_knowledge_article:edit")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
+ public Result<String> edit(@RequestBody Article article) {
|
|
|
+ articleService.updateArticle(article);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
|
|
|
- @AutoLog(value = "知识管理-文章-批量审核")
|
|
|
- @ApiOperation(value="知识管理-文章-批量审核", notes="知识管理-文章-批量审核")
|
|
|
- @RequiresPermissions("kms:kms_knowledge_article:deleteAudit")
|
|
|
- @GetMapping(value = "/auditBatch")
|
|
|
- public Result<String> auditBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
- this.articleService.auditBatchByIds(Arrays.asList(ids.split(",")));
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "知识管理-文章-通过id查询")
|
|
|
- @ApiOperation(value="知识管理-文章-通过id查询", notes="知识管理-文章-通过id查询")
|
|
|
- @GetMapping(value = "/queryById")
|
|
|
- public Result<Article> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
- Article article = articleService.getById(id);
|
|
|
- if(article==null) {
|
|
|
- return Result.error("未找到对应数据");
|
|
|
- }
|
|
|
- return Result.OK(article);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "知识管理-文章-通过id删除")
|
|
|
+ @ApiOperation(value = "知识管理-文章-通过id删除", notes = "知识管理-文章-通过id删除")
|
|
|
+ @RequiresPermissions("kms:kms_knowledge_article:delete")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ articleService.removeById(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "知识管理-文章-批量删除")
|
|
|
+ @ApiOperation(value = "知识管理-文章-批量删除", notes = "知识管理-文章-批量删除")
|
|
|
+ @RequiresPermissions("kms:kms_knowledge_article:deleteBatch")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
+ this.articleService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "知识管理-文章-批量审核")
|
|
|
+ @ApiOperation(value = "知识管理-文章-批量审核", notes = "知识管理-文章-批量审核")
|
|
|
+ @RequiresPermissions("kms:kms_knowledge_article:deleteAudit")
|
|
|
+ @GetMapping(value = "/auditBatch")
|
|
|
+ public Result<String> auditBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
+ this.articleService.auditBatchByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量审核成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "知识管理-文章-通过id查询")
|
|
|
+ @ApiOperation(value = "知识管理-文章-通过id查询", notes = "知识管理-文章-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<Article> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ Article article = articleService.getById(id);
|
|
|
+ if (article == null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ //查询该文章的标签
|
|
|
+ List<ArticleTagR> articleTagRS = articleTagRService.list(new QueryWrapper<ArticleTagR>().lambda().eq(ArticleTagR::getArticleId, article.getId()));
|
|
|
+ //收集标签的tagIds
|
|
|
+ if (!articleTagRS.isEmpty()) {
|
|
|
+ List<String> tags = articleTagRS.stream().map(ArticleTagR::getTagId).collect(Collectors.toList());
|
|
|
+ article.setTags(tags);
|
|
|
+ }
|
|
|
+ return Result.OK(article);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param article
|
|
|
- */
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param article
|
|
|
+ */
|
|
|
@RequiresPermissions("kms:kms_knowledge_article:exportXls")
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Article article) {
|
|
@@ -170,12 +185,12 @@ public class ArticleController extends JeecgController<Article, IArticleService>
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@RequiresPermissions("kms:kms_knowledge_article:importExcel")
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|