|
|
@@ -169,7 +169,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
|
lqw.eq(SysDept::getDelFlag, 0); // 删除标志为未删除
|
|
|
lqw.eq(SysDept::getParentId, sysDept.getParentId()); // 父级部门ID相同
|
|
|
- lqw.ge(SysDept::getOrderNum, sysDept.getOrderNum()); // 排序号大于当前部门
|
|
|
+ lqw.ge(SysDept::getOrderNum, sysDept.getOrderNum()); // 排序号大于等于当前部门
|
|
|
List<SysDept> sysDeptList = list(lqw);
|
|
|
// 更新这些部门的排序号
|
|
|
sysDeptList.forEach(i -> {
|
|
|
@@ -189,10 +189,19 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
qw.eq(SysDept::getDelFlag, 0); // 删除标志为未删除
|
|
|
qw.eq(SysDept::getParentId, record.getParentId()); // 父级部门ID相同
|
|
|
qw.eq(SysDept::getOrderNum, record.getOrderNum()); // 排序号相同
|
|
|
- SysDept sysDept = baseMapper.selectOne(qw);
|
|
|
- if (sysDept != null) {
|
|
|
- sysDept.setOrderNum(sysDept.getOrderNum() + 1);
|
|
|
- baseMapper.updateById(sysDept);
|
|
|
+ boolean exists = baseMapper.exists(qw);
|
|
|
+
|
|
|
+ if (exists){
|
|
|
+ // 如果存在,查询该父级部门下排序号大于当前部门的部门列表
|
|
|
+ LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(SysDept::getDelFlag, 0); // 删除标志为未删除
|
|
|
+ lqw.eq(SysDept::getParentId, record.getParentId()); // 父级部门ID相同
|
|
|
+ lqw.ge(SysDept::getOrderNum, record.getOrderNum()); // 排序号大于等于当前部门
|
|
|
+ List<SysDept> sysDeptList = list(lqw);
|
|
|
+ sysDeptList.forEach(i -> {
|
|
|
+ i.setOrderNum(i.getOrderNum() + 1);
|
|
|
+ updateById(i);
|
|
|
+ });
|
|
|
}
|
|
|
baseMapper.updateById(record);
|
|
|
return HttpResult.ok();
|