| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.system.domain.SysDept; |
| | | import org.dromara.system.domain.SysRoleDept; |
| | | import org.dromara.system.mapper.SysDeptMapper; |
| | | import org.dromara.system.mapper.SysRoleDeptMapper; |
| | | import org.dromara.system.service.ISysDataScopeService; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | * @param roleId 角色Id |
| | | * @return 部门Id组 |
| | | */ |
| | | @Cacheable(cacheNames = CacheNames.SYS_ROLE_CUSTOM, key = "#roleId", condition = "#roleId != null") |
| | | @Override |
| | | public String getRoleCustom(Long roleId) { |
| | | if (ObjectUtil.isNull(roleId)) { |
| | |
| | | * @param deptId 部门Id |
| | | * @return 部门Id组 |
| | | */ |
| | | @Cacheable(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId", condition = "#deptId != null") |
| | | @Override |
| | | public String getDeptAndChild(Long deptId) { |
| | | if (ObjectUtil.isNull(deptId)) { |
| | | return "-1"; |
| | | } |
| | | List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>() |
| | | .select(SysDept::getDeptId) |
| | | .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); |
| | | List<SysDept> deptList = deptMapper.selectListByParentId(deptId); |
| | | List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId); |
| | | ids.add(deptId); |
| | | if (CollUtil.isNotEmpty(ids)) { |