Browse Source

修改:文章分类新增isPublic字段

GDW 11 months ago
parent
commit
c14b446757

+ 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);
+
 
 }

+ 37 - 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,7 +36,7 @@
         (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}
@@ -27,4 +45,21 @@
         ${sql}
     </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>
+    </select>
+
 </mapper>

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

@@ -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;
     }
 
@@ -151,7 +155,13 @@ public class CategoryServiceImpl extends ServiceImpl<KmsCategoryMapper, Category
             pid = ROOT_PID_VALUE;
         }
         String sql = QueryGenerator.installAuthJdbc(Category.class);
-        return baseMapper.queryListByPid(pid, null, sql);
+//        return baseMapper.queryListByPid(pid, null, sql);
+
+        //获取受权限控制的数据
+        List<SelectTreeModel> selectTreeModels = baseMapper.queryListByPidPrivilege(pid, null, sql);
+        //获取公共数据
+        selectTreeModels.addAll(baseMapper.queryListByPidNoPrivilege(pid, null));
+        return selectTreeModels;
     }
 
 	/**