Pārlūkot izejas kodu

标准化测试

LingxinMeng 2 gadi atpakaļ
vecāks
revīzija
0b17ee50a9

+ 1 - 1
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/cofiguration/oauth/OauthAuthorizationServerConfiguration.java

@@ -67,7 +67,7 @@ public class OauthAuthorizationServerConfiguration extends AuthorizationServerCo
                         "simulation-resource-sever"
                 )  // 客户端拥有的资源列表
                 .authorizedGrantTypes("client_credentials", "refresh_token") // 允许的授权方式
-                .scopes("other")    // 授权范围划分
+                .scopes("all")    // 授权范围划分
                 .autoApprove(true)
         ; // 是否自动通过,即是否跳过 scope 选择界面,跳过的话代表将所有 scope 授权范围赋予该 client
     }

+ 34 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/JobManageApplication.java

@@ -1,15 +1,45 @@
 package com.css.simulation.resource.server.application.job_manage;
 
-
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.vo.project.ProjectReportVO;
+import api.common.util.StringUtil;
+import com.css.simulation.resource.server.domain.ProjectDomain;
+import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 
-public interface JobManageApplication {
+@Service
+public class JobManageApplication {
+
+    @Resource
+    private ProjectDomain projectDomain;
+
+    public ProjectReportVO getLastProjectReportByAlgorithmId(String algorithmId) {
+        //1 获取最新的项目ID
+        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
+        if (StringUtil.isEmpty(projectId)) {
+            throw new RuntimeException("该算法还未执行过项目。");
+        }
+        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
 
-    ProjectReportVO getLastProjectReportByAlgorithmId(String  algorithmId);
+        //2 获取报告详情
+        return projectDomain.getProjectReport(SimulationManualProjectParam.builder()
+                .id(projectId)
+                .projectType(projectType)
+                .build());
+    }
 
+    public List<String> getLastVideoListByAlgorithmId(String algorithmId) {
+        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
+        if (StringUtil.isEmpty(projectId)) {
+            throw new RuntimeException("该算法还未执行过项目。");
+        }
+        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
+        return projectDomain.getVideoList(SimulationManualProjectParam.builder()
+                .id(projectId)
+                .projectType(projectType)
+                .build());
+    }
 
-    List<String> getLastVideoListByAlgorithmId(String algorithmId);
 }

+ 0 - 50
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/impl/JobManageApplicationImpl.java

@@ -1,50 +0,0 @@
-package com.css.simulation.resource.server.application.job_manage.impl;
-
-import api.common.pojo.common.ResponseBodyVO;
-import api.common.pojo.param.project.SimulationManualProjectParam;
-import api.common.pojo.vo.project.ProjectReportVO;
-import api.common.util.StringUtil;
-import com.css.simulation.resource.server.application.SimulationProjectService;
-import com.css.simulation.resource.server.application.job_manage.JobManageApplication;
-import com.css.simulation.resource.server.domain.ProjectDomain;
-import org.jvnet.hk2.annotations.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-@Service
-public class JobManageApplicationImpl implements JobManageApplication {
-
-    @Resource
-    private ProjectDomain projectDomain;
-
-    @Override
-    public ProjectReportVO getLastProjectReportByAlgorithmId(String algorithmId) {
-        //1 获取最新的项目ID
-        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
-        if (StringUtil.isEmpty(projectId)) {
-            throw new RuntimeException("该算法还未执行过项目。");
-        }
-        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
-
-        //2 获取报告详情
-        return projectDomain.getProjectReport(SimulationManualProjectParam.builder()
-                .id(projectId)
-                .projectType(projectType)
-                .build());
-    }
-
-    @Override
-    public List<String> getLastVideoListByAlgorithmId(String algorithmId) {
-        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
-        if (StringUtil.isEmpty(projectId)) {
-            throw new RuntimeException("该算法还未执行过项目。");
-        }
-        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
-        return projectDomain.getVideoList(SimulationManualProjectParam.builder()
-                .id(projectId)
-                .projectType(projectType)
-                .build());
-    }
-
-}

+ 1 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/server/domain/ProjectDomain.java

@@ -8,16 +8,14 @@ import api.common.pojo.po.project.SimulationManualProjectPO;
 import api.common.pojo.vo.project.ProjectReportVO;
 import com.css.simulation.resource.server.acl.feign.FileDownService;
 import com.css.simulation.resource.server.application.SimulationProjectService;
-import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationAutomaticSubProjectMapper;
 import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationProjectMapper;
 import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationProjectTaskMapper;
-import org.jvnet.hk2.annotations.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
-@Service
+@org.springframework.stereotype.Service
 public class ProjectDomain {
 
     @Resource

+ 4 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/common/configuration/OAuth2Configuration.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.server.infrastructure.common.configuration;
 
 import com.css.simulation.resource.server.infrastructure.common.oauth.MyUserAuthenticationConverter;
 import com.css.simulation.resource.server.infrastructure.common.oauth.OauthParameter;
+import lombok.SneakyThrows;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.http.SessionCreationPolicy;
@@ -41,12 +42,13 @@ public class OAuth2Configuration extends ResourceServerConfigurerAdapter {
      * 配置拦截请求,通过 scope
      */
     @Override
-    public void configure(HttpSecurity http) throws Exception {
+    @SneakyThrows
+    public void configure(HttpSecurity http) {
         http.csrf().disable()   // 禁用 csrf
                 .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)// 无状态验证
                 .and()
                 .authorizeRequests()
-                .antMatchers("/**/report/**").access("#oauth2.hasScope('other')")//算法平台接口
+                .antMatchers("/**/report/**").access("#oauth2.hasScope('all')")//算法平台接口
                 .antMatchers("/**/monitor/createAutomaticSubProject").permitAll()//定时任务接口
                 .antMatchers("/druid/**").permitAll()
                 .anyRequest().access("#oauth2.hasScope('all')") // 拦截所有请求判断 scope