Browse Source

文章分类树排序

danch 10 months ago
parent
commit
6e9d018411

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

@@ -9,23 +9,23 @@
     </update>
 
     <!-- 【vue3专用】 -->
-<!--    <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="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">
@@ -43,6 +43,7 @@
             </foreach>
         </if>
         ${sql}
+        order by sort_no asc
     </select>
 
     <select id="queryListByPidNoPrivilege" parameterType="java.lang.Object"
@@ -60,6 +61,7 @@
                 and ${key} = #{value}
             </foreach>
         </if>
+        order by sort_no asc
     </select>
 
 </mapper>

+ 1 - 1
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) {