登录用户部门排序问题

This commit is contained in:
2023-04-28 16:00:35 +08:00
parent 0a2c90e354
commit 33c9678661
8 changed files with 66 additions and 65 deletions

View File

@@ -60,29 +60,26 @@
SELECT
T3.*
FROM
(
SELECT
@codes AS _ids,
(
SELECT @codes := GROUP_CONCAT( id ) FROM sys_dept WHERE FIND_IN_SET( pid, @codes ) ) AS T1
FROM
sys_dept s,
( SELECT @codes := #{id} ) T4
WHERE
@codes IS NOT NULL
<if test="type != null">
AND s.type in
<foreach collection="type" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) T2,
sys_dept T3,
sys_area T5
WHERE
FIND_IN_SET( T3.id, T2._ids )
FIND_IN_SET( #{id}, T3.pids )
and t3.type in
<foreach collection="type" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND t3.area = t5.id
AND t3.State = 1
UNION
SELECT
T3.*
FROM
sys_dept T3,
sys_area T5
WHERE
t3.area = t5.id
and T3.id = #{id}
AND t3.State = 1
</select>
<select id="deptArea" resultType="String">

View File

@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -319,7 +320,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
return allDept.stream().filter(dept -> dept.getPid().equals(deptFirst.getId()))
.peek(deptVo -> {
deptVo.setChildren(getChildrens(deptVo, allDept));
}).collect(Collectors.toList());
}).sorted(Comparator.comparing(DeptAllTreeVO::getSort)).collect(Collectors.toList());
}