|
@@ -3,6 +3,8 @@ package com.dayou.aspect;
|
|
import com.dayou.annotation.DataPermission;
|
|
import com.dayou.annotation.DataPermission;
|
|
import com.dayou.bo.SimpleParentModel;
|
|
import com.dayou.bo.SimpleParentModel;
|
|
import com.dayou.common.SimpleListModel;
|
|
import com.dayou.common.SimpleListModel;
|
|
|
|
+import com.dayou.dto.SimplePostModel;
|
|
|
|
+import com.dayou.service.IPostService;
|
|
import com.dayou.service.IUserService;
|
|
import com.dayou.service.IUserService;
|
|
import com.dayou.utils.LoginContext;
|
|
import com.dayou.utils.LoginContext;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -14,10 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -36,6 +35,9 @@ public class DataPermissionAop {
|
|
@Autowired
|
|
@Autowired
|
|
private IUserService userService;
|
|
private IUserService userService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPostService postService;
|
|
|
|
+
|
|
@Pointcut("@annotation(com.dayou.annotation.DataPermission)")
|
|
@Pointcut("@annotation(com.dayou.annotation.DataPermission)")
|
|
public void dataPermissionPointcut(){
|
|
public void dataPermissionPointcut(){
|
|
|
|
|
|
@@ -54,9 +56,25 @@ public class DataPermissionAop {
|
|
if (parentIds.contains(null)){
|
|
if (parentIds.contains(null)){
|
|
return joinPoint.proceed();
|
|
return joinPoint.proceed();
|
|
}
|
|
}
|
|
|
|
+ //部门内部最高岗位拥有该部门最高数据权限,否则只有登录人参与的项目的数据权限
|
|
|
|
+ List<SimplePostModel> postList = LoginContext.getLoginCacheUserBO().getPostList();
|
|
|
|
+
|
|
|
|
+ List<Long> dIds = new ArrayList<>();
|
|
|
|
+ Set<Long> users = new HashSet<>();
|
|
|
|
+ for (SimplePostModel post : postList){
|
|
|
|
+ if (postService.mostHighPost(post)){
|
|
|
|
+ dIds.add(post.getDepartmentId());
|
|
|
|
+ }else {
|
|
|
|
+ users.add(LoginContext.getUserId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
Field departments = arg.getClass().getDeclaredField("departmentIds");
|
|
Field departments = arg.getClass().getDeclaredField("departmentIds");
|
|
departments.setAccessible(Boolean.TRUE);
|
|
departments.setAccessible(Boolean.TRUE);
|
|
- departments.set(arg,ids);
|
|
|
|
|
|
+ departments.set(arg,dIds);
|
|
|
|
+ Field userIds = arg.getClass().getDeclaredField("userIds");
|
|
|
|
+ userIds.setAccessible(Boolean.TRUE);
|
|
|
|
+ userIds.set(arg,users);
|
|
}
|
|
}
|
|
|
|
|
|
if (dataPermission.postChild()){
|
|
if (dataPermission.postChild()){
|