fix(SysDeptServiceImpl.java): 部门无法查询顶级部门问题修复,暂时移除数据权限,等待后续功能完善。

This commit is contained in:
郝先瑞 2022-01-28 23:56:25 +08:00
parent 1a328c97be
commit 730fe7a503
2 changed files with 6 additions and 24 deletions

View File

@ -14,7 +14,7 @@ import java.util.List;
@Mapper @Mapper
public interface SysDeptMapper extends BaseMapper<SysDept> { public interface SysDeptMapper extends BaseMapper<SysDept> {
@DataPermission // @DataPermission
@Override @Override
List<SysDept> selectList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper); List<SysDept> selectList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
} }

View File

@ -10,13 +10,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.admin.constant.SystemConstants; import com.youlai.admin.constant.SystemConstants;
import com.youlai.admin.mapper.SysDeptMapper; import com.youlai.admin.mapper.SysDeptMapper;
import com.youlai.admin.pojo.entity.SysDept; import com.youlai.admin.pojo.entity.SysDept;
import com.youlai.admin.pojo.vo.dept.DeptVO;
import com.youlai.admin.pojo.vo.IdLabelVO; import com.youlai.admin.pojo.vo.IdLabelVO;
import com.youlai.admin.pojo.vo.dept.DeptVO;
import com.youlai.admin.service.ISysDeptService; import com.youlai.admin.service.ISysDeptService;
import com.youlai.admin.service.ISysUserService; import com.youlai.admin.service.ISysUserService;
import com.youlai.common.constant.GlobalConstants; import com.youlai.common.constant.GlobalConstants;
import com.youlai.common.web.util.JwtUtils; import lombok.RequiredArgsConstructor;
import lombok.AllArgsConstructor;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,11 +29,11 @@ import java.util.stream.Collectors;
* @author <a href="mailto:xianrui0365@163.com">haoxr</a> * @author <a href="mailto:xianrui0365@163.com">haoxr</a>
* @date 2021-08-22 * @date 2021-08-22
*/ */
@AllArgsConstructor
@Service @Service
@RequiredArgsConstructor
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService { public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
private ISysUserService iSysUserService; private final ISysUserService iSysUserService;
/** /**
* 部门表格Table层级列表 * 部门表格Table层级列表
@ -120,24 +119,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
.eq(SysDept::getStatus, GlobalConstants.STATUS_YES) .eq(SysDept::getStatus, GlobalConstants.STATUS_YES)
.orderByAsc(SysDept::getSort) .orderByAsc(SysDept::getSort)
); );
List<IdLabelVO> deptSelectList = recursionTreeSelectList( SystemConstants.ROOT_DEPT_ID, deptList);
boolean isRoot = JwtUtils.isRoot();
Long parentId;
if (isRoot) { // 超级管理员
parentId = SystemConstants.ROOT_DEPT_ID;
} else {
Long deptId = JwtUtils.getDeptId();
if (deptId == null) {
return Collections.emptyList();
}
SysDept dept = this.getById(deptId);
if (dept == null) {
return Collections.emptyList();
}
parentId = dept.getParentId();
}
List<IdLabelVO> deptSelectList = recursionTreeSelectList(parentId, deptList);
return deptSelectList; return deptSelectList;
} }