|
@@ -3,9 +3,14 @@ package com.boman.system.service.impl;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.boman.common.core.utils.SecurityUtils;
|
|
|
import com.boman.common.core.utils.number.NumberUtils;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
+import com.boman.common.redis.service.RedisService;
|
|
|
+import com.boman.domain.SysUser;
|
|
|
+import com.boman.domain.constant.CacheConstants;
|
|
|
+import com.boman.system.api.model.LoginUser;
|
|
|
import com.boman.system.mapper.SyncMapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.sun.org.apache.regexp.internal.RE;
|
|
@@ -24,6 +29,8 @@ import com.boman.system.service.ISysDeptService;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import static com.boman.common.datascope.aspect.DataScopeAspect.DATA_SCOPE_ALL;
|
|
|
+
|
|
|
/**
|
|
|
* 部门管理 服务实现
|
|
|
*
|
|
@@ -37,6 +44,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Autowired
|
|
|
private SysRoleMapper roleMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询部门管理数据
|
|
|
*
|
|
@@ -46,15 +56,21 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "d")
|
|
|
public List<SysDept> selectDeptList(SysDept dept) {
|
|
|
+ LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + SecurityUtils.getToken());
|
|
|
+ SysUser sysUser = loginUser.getSysUser();
|
|
|
+ List<SysRole> roles = sysUser.getRoles();
|
|
|
+ dept.setListByParentId(Boolean.TRUE);
|
|
|
+ for (SysRole role : roles) {
|
|
|
+ String dataScope = role.getDataScope();
|
|
|
+ if (DATA_SCOPE_ALL.equals(dataScope)){
|
|
|
+ dept.setListByParentId(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
|
|
|
- dept.setListByParentId(Boolean.TRUE);
|
|
|
return deptMapper.selectDeptList(dept);
|
|
|
}
|
|
|
Long id = dept.getId();
|
|
|
- if (id == null) {
|
|
|
- dept.setListByParentId(Boolean.FALSE);
|
|
|
- } else {
|
|
|
- dept.setListByParentId(Boolean.TRUE);
|
|
|
+ if (id != null) {
|
|
|
dept.setParentId(id);
|
|
|
}
|
|
|
List<SysDept> depts = deptMapper.selectDeptList(dept);
|