1、如下:
public Result<SysDepart> getCurrentLoginUserSchool(){
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
SysDepart sysDepart = sysOrganizationService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getOrgCode,loginUser.getOrgCode()));
sysDepart = getCurrentLoginUserTopDepart(sysDepart);
System.err.println("sysDepart====================="+sysDepart);
return Result.OK(sysDepart);
}
private SysDepart getCurrentLoginUserTopDepart(SysDepart sysDepart){
SysDepart sysDepart1 = sysOrganizationService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getId,sysDepart.getParentId()));
if (sysDepart1 != null){
return getCurrentLoginUserTopDepart(sysDepart1);
}
return sysDepart;
}