Pārlūkot izejas kodu

算法平台接入

WXF 3 gadi atpakaļ
vecāks
revīzija
858454e4b2

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

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

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/config/OAuth2Config.java

@@ -46,6 +46,7 @@ public class OAuth2Config extends ResourceServerConfigurerAdapter {
                 .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)// 无状态验证
                 .and()
                 .authorizeRequests()
+                .antMatchers("/**/report/**").access("#oauth2.hasScope('other')")//算法平台接口
                 .antMatchers("/druid/**").permitAll()
                 .anyRequest().access("#oauth2.hasScope('all')") // 拦截所有请求判断 scope
         ;

+ 38 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/open/ctrl/ReportCtrl.java

@@ -0,0 +1,38 @@
+package com.css.simulation.resource.open.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.vo.project.ProjectReportVo;
+import api.common.util.ObjectUtil;
+import com.css.simulation.resource.open.service.ReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.Map;
+
+@Controller
+@RequestMapping("/report")
+public class ReportCtrl {
+
+    @Autowired
+    ReportService reportService;
+
+    /**
+     * 获取测试报告详情
+     * @param paramMap
+     * @return
+     */
+    @RequestMapping("getSimulationReportById")
+    @ResponseBody
+    public ResponseBodyVO<ProjectReportVo> getSimulationReportById(@RequestBody Map<String,String> paramMap){
+        if(ObjectUtil.isNull(paramMap) || ObjectUtil.isNull(paramMap.get("algorithmId"))){
+            return new ResponseBodyVO(false, 500, "参数必传!",null);
+        }
+        ProjectReportVo reportVo = reportService.getSimulationReportById(paramMap);
+        ResponseBodyVO<ProjectReportVo> response = new ResponseBodyVO<ProjectReportVo>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(reportVo);
+        return response;
+    }
+}

+ 18 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/open/service/ReportService.java

@@ -0,0 +1,18 @@
+package com.css.simulation.resource.open.service;
+
+import api.common.pojo.vo.project.ProjectReportVo;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ReportService {
+    public ProjectReportVo getSimulationReportById(Map<String, String> paramMap) {
+        ProjectReportVo vo = new ProjectReportVo();
+        vo.setAlgorithmName("test");
+        vo.setAlgorithmScore(26.2);
+        return vo;
+    }
+}