|
@ -10,6 +10,8 @@ import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; |
|
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.redis.UserDetailRedis; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
|
|
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
|
|
import com.elink.esua.epdc.dto.DeptOption; |
|
|
import com.elink.esua.epdc.dto.DeptOption; |
|
|
import com.elink.esua.epdc.optimize.constant.OptimizeConstant; |
|
|
import com.elink.esua.epdc.optimize.constant.OptimizeConstant; |
|
@ -40,6 +42,9 @@ public class OptSysDeptServiceImpl extends BaseServiceImpl<OptSysDeptDao, OptSys |
|
|
@Autowired |
|
|
@Autowired |
|
|
private RedisUtils redisUtils; |
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private UserDetailRedis userDetailRedis; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<DeptLevelAndLeaderDTO> listChildDeptLevelById(String typeKey, Long deptId) { |
|
|
public List<DeptLevelAndLeaderDTO> listChildDeptLevelById(String typeKey, Long deptId) { |
|
|
OptSysDeptEntity parentDept = baseDao.selectById(deptId); |
|
|
OptSysDeptEntity parentDept = baseDao.selectById(deptId); |
|
@ -108,6 +113,41 @@ public class OptSysDeptServiceImpl extends BaseServiceImpl<OptSysDeptDao, OptSys |
|
|
return deptOption; |
|
|
return deptOption; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<Long> getUserDeptScope(Long userId, String... typeKeys) { |
|
|
|
|
|
|
|
|
|
|
|
UserDetail userDetail = userDetailRedis.get(userId); |
|
|
|
|
|
if (null == userDetail) { |
|
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
|
} |
|
|
|
|
|
List<Long> deptScope = userDetail.getDeptIdList(); |
|
|
|
|
|
if (null == userDetail.getId() || CollUtil.isEmpty(deptScope)) { |
|
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
|
} |
|
|
|
|
|
// 是否需要对数据权限部门进行二次筛选
|
|
|
|
|
|
boolean filterDataScope = false; |
|
|
|
|
|
if (ArrayUtil.isEmpty(typeKeys)) { |
|
|
|
|
|
typeKeys = new String[]{OptimizeConstant.COMPLETE_DEPT_LEVEL_KEY}; |
|
|
|
|
|
} else { |
|
|
|
|
|
filterDataScope = true; |
|
|
|
|
|
} |
|
|
|
|
|
// 先从redis获取,减少重复查询
|
|
|
|
|
|
String redisKey = OptimizeRedisKeys.getUserDeptScopeKey(userId, StringUtils.join(escapeDeptTypeKey(typeKeys), StrConstant.HYPHEN)); |
|
|
|
|
|
Object obj = redisUtils.get(redisKey); |
|
|
|
|
|
if (null != obj) { |
|
|
|
|
|
return (List<Long>) obj; |
|
|
|
|
|
} |
|
|
|
|
|
// 根据部门类型,二次筛选数据权限部门
|
|
|
|
|
|
if (filterDataScope) { |
|
|
|
|
|
deptScope = baseDao.selectListDeptIdByTypeKeyAndScope(deptScope, typeKeys); |
|
|
|
|
|
} |
|
|
|
|
|
// 存入redis,超时时长设置为一小时
|
|
|
|
|
|
redisUtils.set(redisKey, deptScope, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
|
|
|
|
|
|
|
|
return deptScope; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据部门数据权限组装部门层级结构 |
|
|
* 根据部门数据权限组装部门层级结构 |
|
|
* |
|
|
* |
|
|