Quellcode durchsuchen

2022-9-6 18:17:00 恢复旧有权限获取接口

沈永艺 vor 3 Jahren
Ursprung
Commit
d393be03b7

+ 1 - 0
PAS/pom.xml

@@ -144,6 +144,7 @@
     </dependencies>
 
     <build>
+        <finalName>PAS_TEST</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 41 - 41
PAS/src/main/java/cn/cslg/pas/common/core/annotation/PermissionAspect.java

@@ -30,45 +30,45 @@ import java.util.Arrays;
 @Component
 public class PermissionAspect {
 
-    @Autowired
-    private ProjectUserService projectUserService;
-    @Autowired
-    private ProjectService projectService;
-    @Autowired
-    private CacheUtils cacheUtils;
-    @Autowired
-    private LoginUtils loginUtils;
-    @Pointcut("execution(public * cn.cslg.pas.controller.*.*(..))")
-    public void privilege() {
-    }
-
-    @ResponseBody
-    @Around("privilege()")
-    public Object isAccessMethod(ProceedingJoinPoint joinPoint) throws Throwable {
-        //获取访问目标方法
-        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
-        Method targetMethod = methodSignature.getMethod();
-        final int[] methodAccess = AnnotationParse.permissionParse(targetMethod);
-        if (methodAccess != null && methodAccess.length != 0) {
-            HttpServletRequest request = RequestHolder.getRequest();
-            if (request != null) {
-                String projectId = request.getHeader("x-project-id");
-                Integer userId = loginUtils.getId();
-                if (StringUtils.isNotEmpty(projectId)) {
-                    Project project = projectService.getById(projectId);
-                    User user = cacheUtils.getLoginUser(userId);
-                    ProjectUser projectUser = projectUserService.getProjectUserByProjectIdAndUserId(Integer.parseInt(projectId), userId);
-                    if (projectUser != null && project != null && user != null) {
-                        if (project.getCreateBy().equals(userId)) {
-                            return joinPoint.proceed();
-                        }
-                        if (Arrays.stream(methodAccess).noneMatch(item -> item == projectUser.getType())) {
-                            throw new PermissionException("用户操作拦截");
-                        }
-                    }
-                }
-            }
-        }
-        return joinPoint.proceed();
-    }
+//    @Autowired
+//    private ProjectUserService projectUserService;
+//    @Autowired
+//    private ProjectService projectService;
+//    @Autowired
+//    private CacheUtils cacheUtils;
+//    @Autowired
+//    private LoginUtils loginUtils;
+//    @Pointcut("execution(public * cn.cslg.pas.controller.*.*(..))")
+//    public void privilege() {
+//    }
+//
+//    @ResponseBody
+//    @Around("privilege()")
+//    public Object isAccessMethod(ProceedingJoinPoint joinPoint) throws Throwable {
+//        //获取访问目标方法
+//        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
+//        Method targetMethod = methodSignature.getMethod();
+//        final int[] methodAccess = AnnotationParse.permissionParse(targetMethod);
+//        if (methodAccess != null && methodAccess.length != 0) {
+//            HttpServletRequest request = RequestHolder.getRequest();
+//            if (request != null) {
+//                String projectId = request.getHeader("x-project-id");
+//                Integer userId = loginUtils.getId();
+//                if (StringUtils.isNotEmpty(projectId)) {
+//                    Project project = projectService.getById(projectId);
+//                    User user = cacheUtils.getLoginUser(userId);
+//                    ProjectUser projectUser = projectUserService.getProjectUserByProjectIdAndUserId(Integer.parseInt(projectId), userId);
+//                    if (projectUser != null && project != null && user != null) {
+//                        if (project.getCreateBy().equals(userId)) {
+//                            return joinPoint.proceed();
+//                        }
+//                        if (Arrays.stream(methodAccess).noneMatch(item -> item == projectUser.getType())) {
+//                            throw new PermissionException("用户操作拦截");
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return joinPoint.proceed();
+//    }
 }

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/common/utils/CacheUtils.java

@@ -40,12 +40,12 @@ public class CacheUtils {
         redisUtil.set(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + user.getId(), JsonUtils.objectToJson(user));
     }
 
-    public User getLoginUser(Object userId) {
+    public PersonnelVO getLoginUser(Object userId) {
         String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
         if (StringUtils.isEmpty(json)) {
             throw new NotLoginException("无数据", "user", "");
         } else {
-            return JsonUtils.jsonToPojo(json, User.class);
+            return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);
         }
     }
 

+ 5 - 5
PAS/src/main/java/cn/cslg/pas/service/OAuth2Service.java

@@ -43,16 +43,16 @@ public class OAuth2Service {
     private String url;
     public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
 
-    public User getUserinfo() {
+    public PersonnelVO getUserinfo() {
         Integer userId = loginUtils.getId();
-        User user = cacheUtils.getLoginUser(userId);
-        user.setPassword(null);
-        return user;
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(userId);
+        personnelVO.setPassword(null);
+        return personnelVO;
     }
 
     public Map<Integer, Integer> getPermissions() {
         Map<Integer, Integer> result = new HashMap<>();
-        User user = this.getUserinfo();
+        PersonnelVO user = this.getUserinfo();
         if (user.getUsername().equals(Constants.ADMIN_USERNAME)) {
             List<Project> projectList = projectService.list();
             for (Project project : projectList) {

+ 1 - 0
PAS/src/main/java/cn/cslg/pas/service/ProjectService.java

@@ -415,6 +415,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         user.setUserId(loginUtils.getId());
         user.setProjectId(projectId);
         user.setCreateTime(DateUtils.getDateTime());
+        user.setType(2);
         user.insert();
     }