修复 部门树排序问题

This commit is contained in:
数据小王子 2024-02-26 17:24:56 +08:00
parent 885918d11f
commit 29a620eb41

View File

@ -73,7 +73,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
.and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId())) .and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId()))
.and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName())) .and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName()))
.and(SYS_DEPT.STATUS.eq(deptBo.getStatus())) .and(SYS_DEPT.STATUS.eq(deptBo.getStatus()))
.orderBy(SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc()); .orderBy(SYS_DEPT.ANCESTORS.asc(), SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc());
return queryWrapper; return queryWrapper;
} }
@ -148,7 +148,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
if (ObjectUtil.isNotNull(role.getDeptCheckStrictly()) && role.getDeptCheckStrictly().equals(true)) { if (ObjectUtil.isNotNull(role.getDeptCheckStrictly()) && role.getDeptCheckStrictly().equals(true)) {
queryWrapper.and(SYS_DEPT.DEPT_ID.notIn(select(SYS_DEPT.PARENT_ID).from(SYS_DEPT).innerJoin(SYS_ROLE_DEPT).on(SYS_ROLE_DEPT.DEPT_ID.eq(SYS_DEPT.DEPT_ID).and(SYS_ROLE_DEPT.ROLE_ID.eq(roleId))))); queryWrapper.and(SYS_DEPT.DEPT_ID.notIn(select(SYS_DEPT.PARENT_ID).from(SYS_DEPT).innerJoin(SYS_ROLE_DEPT).on(SYS_ROLE_DEPT.DEPT_ID.eq(SYS_DEPT.DEPT_ID).and(SYS_ROLE_DEPT.ROLE_ID.eq(roleId)))));
} }
queryWrapper.orderBy(SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc()); queryWrapper.orderBy(SYS_DEPT.ANCESTORS.asc(), SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc());
return this.listAs(queryWrapper, Long.class); return this.listAs(queryWrapper, Long.class);