11 Commits 4947efc7e5 ... e2dccfc4c1

Author SHA1 Message Date
  GDW e2dccfc4c1 修改:文章在编辑时isPublic值跟随分类改变 10 months ago
  GDW 6e34835d7f 修改:文章新增isPublic变量,标记是否公开,并根据此变量控制显示 10 months ago
  danch 6e9d018411 文章分类树排序 10 months ago
  GDW c14b446757 修改:文章分类新增isPublic字段 11 months ago
  GDW fee3136da2 Merge branch 'GDW' into dev 11 months ago
  GDW 2d7807cadb 修改:文章分类权限控制 11 months ago
  danch 8dca50e315 列表请求处理 11 months ago
  danch f0872129c8 1. 写编辑文章 保存 发布逻辑清晰 交互逻辑 11 months ago
  GDW 43dfd3506a 修改:取消验证码 11 months ago
  danch e36eadfada 修改错误提示 11 months ago
  danch 059d9c1545 修改错误提示 11 months ago

+ 5 - 0
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/bas/entity/Category.java

@@ -70,4 +70,9 @@ public class Category implements Serializable {
 	@Excel(name = "排序号", width = 15)
     @ApiModelProperty(value = "排序号")
     private Integer sortNo;
+
+    /**是否公开*/
+    @ApiModelProperty(value = "是否公开")
+    private String isPublic;
+
 }

+ 12 - 1
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/bas/mapper/KmsCategoryMapper.java

@@ -31,6 +31,17 @@ public interface KmsCategoryMapper extends BaseMapper<Category> {
 	 * @param query
 	 * @return
 	 */
-	List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query, @Param("sql") String sql);
+//	List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query, @Param("sql") String sql);
+
+	/**
+	 * 获取受权限控制的数据
+	 */
+	List<SelectTreeModel> queryListByPidPrivilege(@Param("pid") String pid, @Param("query") Map<String, String> query, @Param("sql") String sql);
+
+	/**
+	 * 获取公共数据
+	 */
+	List<SelectTreeModel> queryListByPidNoPrivilege(@Param("pid") String pid, @Param("query") Map<String, String> query);
+
 
 }

+ 39 - 2
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/bas/mapper/xml/KmsCategoryMapper.xml

@@ -9,7 +9,25 @@
     </update>
 
     <!-- 【vue3专用】 -->
-    <select id="queryListByPid" parameterType="java.lang.Object"
+    <!--    <select id="queryListByPid" parameterType="java.lang.Object"-->
+    <!--            resultType="org.jeecg.common.system.vo.SelectTreeModel">-->
+    <!--        select-->
+    <!--        id as "key",-->
+    <!--        name as "title",-->
+    <!--        id as "value",-->
+    <!--        (case when has_child = '1' then 0 else 1 end) as isLeaf,-->
+    <!--        pid as parentId-->
+    <!--        from kms_bas_article_category-->
+    <!--        where pid = #{pid}-->
+    <!--        <if test="query != null">-->
+    <!--            <foreach collection="query.entrySet()" item="value" index="key">-->
+    <!--                and ${key} = #{value}-->
+    <!--            </foreach>-->
+    <!--        </if>-->
+    <!--        ${sql}-->
+    <!--    </select>-->
+
+    <select id="queryListByPidPrivilege" parameterType="java.lang.Object"
             resultType="org.jeecg.common.system.vo.SelectTreeModel">
         select
         id as "key",
@@ -18,13 +36,32 @@
         (case when has_child = '1' then 0 else 1 end) as isLeaf,
         pid as parentId
         from kms_bas_article_category
-        where pid = #{pid}
+        where pid = #{pid} AND (is_public IS NULL OR is_public = '0')
         <if test="query != null">
             <foreach collection="query.entrySet()" item="value" index="key">
                 and ${key} = #{value}
             </foreach>
         </if>
         ${sql}
+        order by sort_no asc
+    </select>
+
+    <select id="queryListByPidNoPrivilege" parameterType="java.lang.Object"
+            resultType="org.jeecg.common.system.vo.SelectTreeModel">
+        select
+        id as "key",
+        name as "title",
+        id as "value",
+        (case when has_child = '1' then 0 else 1 end) as isLeaf,
+        pid as parentId
+        from kms_bas_article_category
+        where pid = #{pid} and is_public = '1'
+        <if test="query != null">
+            <foreach collection="query.entrySet()" item="value" index="key">
+                and ${key} = #{value}
+            </foreach>
+        </if>
+        order by sort_no asc
     </select>
 
 </mapper>

+ 15 - 4
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/bas/service/impl/CategoryServiceImpl.java

@@ -128,7 +128,7 @@ public class CategoryServiceImpl extends ServiceImpl<KmsCategoryMapper, Category
         String pid = ROOT_PID_VALUE;
         if (oConvertUtils.isNotEmpty(parentCode)) {
             QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(Category::getPid, parentCode);
+            queryWrapper.lambda().eq(Category::getPid, parentCode).orderByAsc(Category::getSortNo);
             QueryGenerator.installAuthMplus(queryWrapper, Category.class);
             List<Category> list = baseMapper.selectList(queryWrapper);
             if (list == null || list.size() == 0) {
@@ -140,8 +140,12 @@ public class CategoryServiceImpl extends ServiceImpl<KmsCategoryMapper, Category
             pid = list.get(0).getId();
         }
         String sql = QueryGenerator.installAuthJdbc(Category.class);
-        System.out.println(sql);
-        List<SelectTreeModel> selectTreeModels = baseMapper.queryListByPid(pid, null, sql);
+        //获取受权限控制的数据
+//        List<SelectTreeModel> selectTreeModels = baseMapper.queryListByPid(pid, null, sql);
+        List<SelectTreeModel> selectTreeModels = baseMapper.queryListByPidPrivilege(pid, null, sql);
+        //获取公共数据
+        selectTreeModels.addAll(baseMapper.queryListByPidNoPrivilege(pid, null));
+
         return selectTreeModels;
     }
 
@@ -150,7 +154,14 @@ public class CategoryServiceImpl extends ServiceImpl<KmsCategoryMapper, Category
         if (oConvertUtils.isEmpty(pid)) {
             pid = ROOT_PID_VALUE;
         }
-        return baseMapper.queryListByPid(pid, null, "");
+        String sql = QueryGenerator.installAuthJdbc(Category.class);
+//        return baseMapper.queryListByPid(pid, null, sql);
+
+        //获取受权限控制的数据
+        List<SelectTreeModel> selectTreeModels = baseMapper.queryListByPidPrivilege(pid, null, sql);
+        //获取公共数据
+        selectTreeModels.addAll(baseMapper.queryListByPidNoPrivilege(pid, null));
+        return selectTreeModels;
     }
 
 	/**

+ 143 - 128
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/controller/ArticleController.java

@@ -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) {

+ 57 - 25
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/entity/Article.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.kms.knowledge.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -15,66 +16,91 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Description: 知识管理-文章
  * @Author: jeecg-boot
- * @Date:   2023-12-08
+ * @Date: 2023-12-08
  * @Version: V1.0
  */
 @Data
 @TableName("kms_knowledge_article")
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
-@ApiModel(value="kms_knowledge_article对象", description="知识管理-文章")
+@ApiModel(value = "kms_knowledge_article对象", description = "知识管理-文章")
 public class Article implements Serializable {
     private static final long serialVersionUID = 1L;
 
-	/**主键*/
-	@TableId(type = IdType.ASSIGN_ID)
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "主键")
     private String id;
-	/**创建人*/
+    /**
+     * 创建人
+     */
     @ApiModelProperty(value = "创建人")
     private String createBy;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    /**
+     * 创建日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建日期")
     private Date createTime;
-	/**更新人*/
+    /**
+     * 更新人
+     */
     @ApiModelProperty(value = "更新人")
     private String updateBy;
-	/**更新日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    /**
+     * 更新日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "更新日期")
     private Date updateTime;
-	/**所属部门*/
+    /**
+     * 所属部门
+     */
     @ApiModelProperty(value = "所属部门")
     private String sysOrgCode;
-	/**标题*/
-	@Excel(name = "标题", width = 15)
+    /**
+     * 标题
+     */
+    @Excel(name = "标题", width = 15)
     @ApiModelProperty(value = "标题")
     private String title;
-	/**封面*/
-	@Excel(name = "封面", width = 15)
+    /**
+     * 封面
+     */
+    @Excel(name = "封面", width = 15)
     @ApiModelProperty(value = "封面")
     private String cover;
-	/**导读*/
-	@Excel(name = "导读", width = 15)
+    /**
+     * 导读
+     */
+    @Excel(name = "导读", width = 15)
     @ApiModelProperty(value = "导读")
     private String guide;
-	/**内容*/
-	@Excel(name = "内容", width = 15)
+    /**
+     * 内容
+     */
+    @Excel(name = "内容", width = 15)
     @ApiModelProperty(value = "内容")
     private String content;
-	/**访问数量*/
-	@Excel(name = "访问数量", width = 15)
+    /**
+     * 访问数量
+     */
+    @Excel(name = "访问数量", width = 15)
     @ApiModelProperty(value = "访问数量")
     private Integer visit;
-	/**所属分类*/
-	@Excel(name = "所属分类", width = 15)
+    /**
+     * 所属分类
+     */
+    @Excel(name = "所属分类", width = 15)
     @ApiModelProperty(value = "所属分类")
     @Dict(dictTable = "kms_bas_article_category", dicCode = "id", dicText = "name")
     private String categoryId;
@@ -86,4 +112,10 @@ public class Article implements Serializable {
      * 3驳回**/
     private Integer status;
     private String authorId;
+    @TableField(exist = false)
+    private List<String> tags;
+
+    @Excel(name = "是否公开", width = 15)
+    @ApiModelProperty(value = "是否公开")
+    private String isPublic;
 }

+ 27 - 1
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/mapper/xml/ArticleMapper.xml

@@ -4,8 +4,9 @@
 
     <select id="queryPageListByFilters" resultType="org.jeecg.modules.kms.knowledge.entity.Article">
         select distinct t0.* from kms_knowledge_article t0
-                          inner join kms_article_category_r t1 on t0.id = t1.article_id
+        inner join kms_article_category_r t1 on t0.id = t1.article_id
         where t0.status = 2
+        AND t0.is_public != '1'
         <if test="filterParam.categoryId != null and filterParam.categoryId != ''">
             AND t1.category_id = #{filterParam.categoryId}
         </if>
@@ -13,5 +14,30 @@
             AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')
         </if>
         ${sql}
+
+        UNION
+
+        select distinct t0.* from kms_knowledge_article t0
+        inner join kms_article_category_r t1 on t0.id = t1.article_id
+        where t0.status = 2
+        AND t0.is_public != '0'
+        <if test="filterParam.categoryId != null and filterParam.categoryId != ''">
+            AND t1.category_id = #{filterParam.categoryId}
+        </if>
+        <if test="filterParam.keyWords != null and filterParam.keyWords != ''">
+            AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')
+        </if>
     </select>
+<!--    <select id="queryPageListByFilters" resultType="org.jeecg.modules.kms.knowledge.entity.Article">-->
+<!--            select distinct t0.* from kms_knowledge_article t0-->
+<!--                              inner join kms_article_category_r t1 on t0.id = t1.article_id-->
+<!--            where t0.status = 2 AND t0.is_public != '1'-->
+<!--            <if test="filterParam.categoryId != null and filterParam.categoryId != ''">-->
+<!--                AND t1.category_id = #{filterParam.categoryId}-->
+<!--            </if>-->
+<!--            <if test="filterParam.keyWords != null and filterParam.keyWords != ''">-->
+<!--                AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')-->
+<!--            </if>-->
+<!--            ${sql}-->
+<!--    </select>-->
 </mapper>

+ 52 - 2
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/service/impl/ArticleServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.kms.bas.entity.Category;
 import org.jeecg.modules.kms.bas.service.ICategoryService;
 import org.jeecg.modules.kms.knowledge.entity.Article;
 import org.jeecg.modules.kms.knowledge.entity.ArticleCategoryR;
@@ -15,11 +16,15 @@ import org.jeecg.modules.kms.knowledge.mapper.ArticleMapper;
 import org.jeecg.modules.kms.knowledge.param.FilterParam;
 import org.jeecg.modules.kms.knowledge.service.IArticleCategoryRService;
 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.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 知识管理-文章
@@ -34,7 +39,8 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
     private ArticleMapper articleMapper;
     @Resource
     private ICategoryService categoryService;
-
+    @Resource
+    private IArticleTagRService articleTagRService;
     @Resource
     private IArticleCategoryRService articleCategoryRService;
     @Resource
@@ -45,17 +51,48 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
         Page<Article> pages = new Page<Article>(filterParam.getPageNo(), filterParam.getPageSize());
         String sql = QueryGenerator.installAuthJdbc(Article.class);
         IPage<Article> articleIPage = articleMapper.queryPageListByFilters(pages, filterParam.getArticleFilterParam(), sql);
+        List<Article> articles = articleIPage.getRecords();
+        for (Article article : articles) {//查询该文章的标签
+            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);
+            }
+        }
+        articleIPage.setRecords(articles);
         return articleIPage;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Article addArticle(Article article) {
-        this.save(article);
+        String categoryId = article.getCategoryId();
+        Category category = categoryService.getById(categoryId);
+        if (category.getIsPublic().equals("1")){
+            article.setIsPublic("1");
+        } else {
+            article.setIsPublic("0");
+        }
+        this.saveOrUpdate(article);
         this.updateCategoryR(article);
+        this.saveOrUpdateTagR(article);
         return article;
     }
 
+    private void saveOrUpdateTagR(Article article) {
+        List<ArticleTagR> articleTagRList = new ArrayList<>();
+        if (article.getTags() != null) {
+            article.getTags().forEach(item -> {
+                ArticleTagR articleTagR = new ArticleTagR();
+                articleTagR.setArticleId(article.getId());
+                articleTagR.setTagId(item);
+                articleTagRList.add(articleTagR);
+            });
+        }
+        articleTagRService.saveOrUpdateBatch(articleTagRList);
+    }
+
     private void updateCategoryR(Article article) {
         List<String> categoryIds = categoryService.getAllParentNodeById(article.getCategoryId());
         categoryIds.forEach(item -> {
@@ -72,9 +109,22 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
 
     @Override
     public void updateArticle(Article article) {
+        String categoryId = article.getCategoryId();
+        Category category = categoryService.getById(categoryId);
+        if (category.getIsPublic().equals("1")){
+            article.setIsPublic("1");
+        } else {
+            article.setIsPublic("0");
+        }
         this.deleteCategoryR(article.getId());
+        this.deleteTagR(article.getId());
         this.updateById(article);
         this.updateCategoryR(article);
+        this.saveOrUpdateTagR(article);
+    }
+
+    private void deleteTagR(String articleId) {
+        articleTagRService.remove(new QueryWrapper<ArticleTagR>().lambda().eq(ArticleTagR::getArticleId, articleId));
     }
 
     @Override

+ 23 - 23
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -88,26 +88,26 @@ public class LoginController {
 		//update-begin--Author:scott  Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
 
 		//update-begin-author:taoyan date:20190828 for:校验验证码
-        String captcha = sysLoginModel.getCaptcha();
-        if(captcha==null){
-            result.error500("验证码无效");
-            return result;
-        }
-        String lowerCaseCaptcha = captcha.toLowerCase();
-        //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
-		// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
-        String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
-		String realKey = Md5Util.md5Encode(origin, "utf-8");
-		//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
-		Object checkCode = redisUtil.get(realKey);
+//        String captcha = sysLoginModel.getCaptcha();
+//        if(captcha==null){
+//            result.error500("验证码无效");
+//            return result;
+//        }
+//        String lowerCaseCaptcha = captcha.toLowerCase();
+//        //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
+//		// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
+//        String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
+//		String realKey = Md5Util.md5Encode(origin, "utf-8");
+//		//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
+//		Object checkCode = redisUtil.get(realKey);
 		//当进入登录页时,有一定几率出现验证码错误 #1714
-		if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
-            log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
-			result.error500("验证码错误");
-			// 改成特殊的code 便于前端判断
-			result.setCode(HttpStatus.PRECONDITION_FAILED.value());
-			return result;
-		}
+//		if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
+//            log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
+//			result.error500("验证码错误");
+//			// 改成特殊的code 便于前端判断
+//			result.setCode(HttpStatus.PRECONDITION_FAILED.value());
+//			return result;
+//		}
 		//update-end-author:taoyan date:20190828 for:校验验证码
 		
 		//1. 校验用户是否有效
@@ -134,10 +134,10 @@ public class LoginController {
 				
 		//用户登录信息
 		userInfo(sysUser, result);
-		//update-begin--Author:liusq  Date:20210126  for:登录成功,删除redis中的验证码
-		redisUtil.del(realKey);
-		//update-begin--Author:liusq  Date:20210126  for:登录成功,删除redis中的验证码
-		redisUtil.del(CommonConstant.LOGIN_FAIL + username);
+//		//update-begin--Author:liusq  Date:20210126  for:登录成功,删除redis中的验证码
+//		redisUtil.del(realKey);
+//		//update-begin--Author:liusq  Date:20210126  for:登录成功,删除redis中的验证码
+//		redisUtil.del(CommonConstant.LOGIN_FAIL + username);
 		LoginUser loginUser = new LoginUser();
 		BeanUtils.copyProperties(sysUser, loginUser);
 		baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null,loginUser);