|
|
@@ -3,13 +3,13 @@ package com.cloud.sa.admin.module.system.datascope.service;
|
|
|
import com.cloud.sa.admin.module.system.datascope.constant.DataScopeTypeEnum;
|
|
|
import com.cloud.sa.admin.module.system.datascope.constant.DataScopeViewTypeEnum;
|
|
|
import com.cloud.sa.admin.module.system.department.service.DepartmentService;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
import com.cloud.sa.admin.module.system.employee.dao.EmployeeDao;
|
|
|
import com.cloud.sa.admin.module.system.employee.domain.entity.EmployeeEntity;
|
|
|
import com.cloud.sa.admin.module.system.role.dao.RoleDataScopeDao;
|
|
|
import com.cloud.sa.admin.module.system.role.dao.RoleEmployeeDao;
|
|
|
import com.cloud.sa.admin.module.system.role.domain.entity.RoleDataScopeEntity;
|
|
|
import com.cloud.sa.base.common.util.BlinkEnumUtil;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -24,8 +24,6 @@ import java.util.stream.Collectors;
|
|
|
*
|
|
|
* @Author 云畅联: admin
|
|
|
* @Date 2020/11/28 20:59:17
|
|
|
-
|
|
|
- *
|
|
|
*/
|
|
|
@Service
|
|
|
public class DataScopeViewService {
|
|
|
@@ -45,8 +43,9 @@ public class DataScopeViewService {
|
|
|
/**
|
|
|
* 获取某人可以查看的所有人员信息
|
|
|
*/
|
|
|
- public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
|
|
- DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
|
|
+// public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
|
|
+// DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
|
|
+ public List<Long> getCanViewEmployeeId(DataScopeViewTypeEnum viewType, Long employeeId) {
|
|
|
if (DataScopeViewTypeEnum.ME == viewType) {
|
|
|
return this.getMeEmployeeIdList(employeeId);
|
|
|
}
|
|
|
@@ -62,10 +61,13 @@ public class DataScopeViewService {
|
|
|
/**
|
|
|
* 获取某人可以查看的所有部门信息
|
|
|
*/
|
|
|
- public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
|
|
- DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
|
|
+// public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
|
|
+// DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
|
|
+ public List<Long> getCanViewDepartmentId(DataScopeViewTypeEnum viewType, Long employeeId) {
|
|
|
if (DataScopeViewTypeEnum.ME == viewType) {
|
|
|
- return this.getMeDepartmentIdList(employeeId);
|
|
|
+ //return this.getMeDepartmentIdList(employeeId);
|
|
|
+ // 数据可见范围类型为本人时 不可以查看任何部门数据
|
|
|
+ return Lists.newArrayList(0L);
|
|
|
}
|
|
|
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
|
|
|
return this.getMeDepartmentIdList(employeeId);
|
|
|
@@ -90,7 +92,9 @@ public class DataScopeViewService {
|
|
|
* 根据员工id 获取各数据范围最大的可见范围 map<dataScopeType,viewType></>
|
|
|
*/
|
|
|
public DataScopeViewTypeEnum getEmployeeDataScopeViewType(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
|
|
- if (employeeId == null) {
|
|
|
+ EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
|
|
+ if (employeeEntity == null || employeeEntity.getEmployeeId() == null) {
|
|
|
+// if (employeeId == null) {
|
|
|
return DataScopeViewTypeEnum.ME;
|
|
|
}
|
|
|
|
|
|
@@ -99,6 +103,10 @@ public class DataScopeViewService {
|
|
|
if (CollectionUtils.isEmpty(roleIdList)) {
|
|
|
return DataScopeViewTypeEnum.ME;
|
|
|
}
|
|
|
+ // 如果是超级管理员 则可查看全部
|
|
|
+ if (employeeEntity.getAdministratorFlag()) {
|
|
|
+ return DataScopeViewTypeEnum.ALL;
|
|
|
+ }
|
|
|
//未设置角色数据范围 默认本人
|
|
|
List<RoleDataScopeEntity> dataScopeRoleList = roleDataScopeDao.listByRoleIdList(roleIdList);
|
|
|
if (CollectionUtils.isEmpty(dataScopeRoleList)) {
|