解决部门id无法查询到部门的空指针异常

This commit is contained in:
抓蛙师 2023-02-17 11:16:17 +08:00
parent 6f209cad99
commit 40aeeeced1
1 changed files with 3 additions and 0 deletions

View File

@ -116,6 +116,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public SysDept selectDeptById(Long deptId) {
SysDept dept = baseMapper.selectById(deptId);
if (ObjectUtil.isNull(dept)) {
return null;
}
SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);