LingxinMeng 2 vuotta sitten
vanhempi
commit
870d849ca5

+ 6 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/controller/AlgorithmController.java

@@ -34,7 +34,7 @@ public class AlgorithmController {
      * 新增/修改算法
      */
     @RequestMapping("addOrUpdate")
-    public ResponseBodyVO<Void> addOrUpdate(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> addOrUpdate(@RequestBody AlgorithmParameter param) {
         return algorithmService.addOrUpdate(param);
     }
 
@@ -43,7 +43,7 @@ public class AlgorithmController {
      * 查询算法列表-私有导入和私有仓库页面
      */
     @RequestMapping("selectAlgorithmList")
-    public ResponseBodyVO selectAlgorithmList(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectAlgorithmList(@RequestBody AlgorithmParameter param) {
         return algorithmService.selectAlgorithmList(param);
     }
 
@@ -51,7 +51,7 @@ public class AlgorithmController {
      * 查询算法列表-算法平台页面
      */
     @RequestMapping("selectAlgoPlatformList")
-    public ResponseBodyVO selectAlgoPlatformList(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectAlgoPlatformList(@RequestBody AlgorithmParameter param) {
         return algorithmService.selectAlgoPlatformList(param);
     }
 
@@ -60,7 +60,7 @@ public class AlgorithmController {
      * 查询算法列表-公有页面
      */
     @RequestMapping("selectSharedAlgorithmList")
-    public ResponseBodyVO selectSharedAlgorithmList(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectSharedAlgorithmList(@RequestBody AlgorithmParameter param) {
         return algorithmService.selectSharedAlgorithmList(param);
     }
 
@@ -78,7 +78,7 @@ public class AlgorithmController {
      * 分享算法
      */
     @RequestMapping("shareAlgorithm")
-    public ResponseBodyVO shareAlgorithm(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> shareAlgorithm(@RequestBody AlgorithmParameter param) {
         return algorithmService.shareAlgorithm(param);
     }
 
@@ -87,7 +87,7 @@ public class AlgorithmController {
      * 查看算法详情
      */
     @RequestMapping("selectDetailsById")
-    public ResponseBodyVO selectDetailsById(@RequestBody AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectDetailsById(@RequestBody AlgorithmParameter param) {
         String algorithmId = param.getId();
         return algorithmService.selectDetailsById(algorithmId);
     }

+ 6 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java

@@ -8,21 +8,21 @@ import java.util.Map;
 
 public interface AlgorithmService {
 
-    ResponseBodyVO<Void> addOrUpdate(AlgorithmParameter param);
+    ResponseBodyVO<Object> addOrUpdate(AlgorithmParameter param);
 
-    ResponseBodyVO selectAlgorithmList(AlgorithmParameter param);
+    ResponseBodyVO<Object> selectAlgorithmList(AlgorithmParameter param);
 
-    ResponseBodyVO selectAlgoPlatformList(AlgorithmParameter param);
+    ResponseBodyVO<Object> selectAlgoPlatformList(AlgorithmParameter param);
 
     ResponseBodyVO<String> deleteById(AlgorithmParameter param);
 
     ResponseBodyVO<Map<String,String>> deleteCheck(AlgorithmParameter param);
 
-    ResponseBodyVO selectDetailsById(String algorithmId);
+    ResponseBodyVO<Object> selectDetailsById(String algorithmId);
 
-    ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param);
+    ResponseBodyVO<Object> selectSharedAlgorithmList(AlgorithmParameter param);
 
-    ResponseBodyVO shareAlgorithm(AlgorithmParameter param);
+    ResponseBodyVO<Object> shareAlgorithm(AlgorithmParameter param);
 
     ResponseBodyVO<String> testConnection(AlgorithmParameter param);
 

+ 10 - 42
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/impl/AlgorithmServiceImpl.java

@@ -66,7 +66,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
     @Override
     @SneakyThrows
-    public ResponseBodyVO<Void> addOrUpdate(AlgorithmParameter param) {
+    public ResponseBodyVO<Object> addOrUpdate(AlgorithmParameter param) {
         String currentUserId = AuthUtil.getCurrentUserId();
         param.setCreateUserId(currentUserId);
 
@@ -100,7 +100,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         return doAddOrUpdate(param);
     }
 
-    private ResponseBodyVO<Void> doAddOrUpdate(AlgorithmParameter param) {
+    private ResponseBodyVO<Object> doAddOrUpdate(AlgorithmParameter param) {
         if (isEmpty(param.getId())) {
             // 添加
             String algorithmId = StringUtil.getRandomUUID();
@@ -130,7 +130,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO selectAlgorithmList(AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectAlgorithmList(AlgorithmParameter param) {
         param.setIsDeleted("0");
         param.setCreateUserId(AuthUtil.getCurrentUserId());
         PageUtil.setPageInfo(param);
@@ -142,7 +142,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO selectAlgoPlatformList(AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectAlgoPlatformList(AlgorithmParameter param) {
         //获取参数
         String algorithmId = param.getAlgorithmCode();
         String algorithmName = param.getAlgorithmName();
@@ -209,7 +209,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
 
     @Override
-    public ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param) {
+    public ResponseBodyVO<Object> selectSharedAlgorithmList(AlgorithmParameter param) {
         param.setShare("1");
         PageUtil.setPageInfo(param);
         List<AlgorithmVO> vos = algorithmMapper.selectSharedAlgorithmList(param);
@@ -220,7 +220,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO<String> shareAlgorithm(AlgorithmParameter param) {
+    public ResponseBodyVO<Object> shareAlgorithm(AlgorithmParameter param) {
         if (isEmpty(param.getId())) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
         } else {
@@ -255,35 +255,6 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         }
     }
 
-//    @Override
-//    public String getGitVersion(String algorithmId) {
-//        AlgorithmPO algorithmPO = algorithmMapper.selectDetailsById(algorithmId);
-//        String gitUrl = algorithmPO.getGitUrl();
-//        String gitUserName = algorithmPO.getGitUserName();
-//        String gitPassword = algorithmPO.getGitPassword();
-//        if (StringUtil.isEmpty(gitUrl)) {
-//            return "";
-//        }
-//        //拼接get请求地址
-////        String prefix = "https://api.github.com/repos/";
-//        String prefix = "https://api.github.com/repos/";
-//        String suffix = "/commits?page=1&per_page=1";
-//        String gitInfo = gitUrl.substring(19, gitUrl.length() - 4);
-//        String requestUrl = prefix + gitInfo + suffix;
-//        try {
-//            String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
-//            List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
-//            if (hashMaps.size() > 0) {
-//                HashMap hashMap = hashMaps.get(0);
-//                String version = hashMap.get("sha").toString();
-//                return version;
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        return StringUtil.getRandomCode();
-//    }
-
     @Override
     public String getGitVersion(String algorithmId) {
         AlgorithmPO algorithmPO = algorithmMapper.selectDetailsById(algorithmId);
@@ -291,7 +262,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         String replace = gitUrl.replace(gitConfiguration.getName(), gitConfiguration.getUrl());
         String gitUserName = algorithmPO.getGitUserName();
         String gitPassword = algorithmPO.getGitPassword();
-        return GitLabUtil.getLastCommitTimestamp(replace, gitUserName, gitPassword) + "";
+        return String.valueOf(GitLabUtil.getLastCommitTimestamp(replace, gitUserName, gitPassword));
     }
 
     @Override
@@ -356,9 +327,9 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO selectDetailsById(String algorithmId) {
+    public ResponseBodyVO<Object> selectDetailsById(String algorithmId) {
         if (isEmpty(algorithmId)) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
         } else {
             AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
             po.setValidationStatus(getDictName(DictConstants.VALIDATION_STATUS, po.getValidationStatus()));
@@ -373,10 +344,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
             return true;
         }
         value = value.trim();
-        if (value.length() == 0) {
-            return true;
-        }
-        return false;
+        return value.length() == 0;
     }
 
 

+ 2 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/common/exception/GlobalExceptionHandler.java

@@ -6,21 +6,19 @@ import org.springframework.context.annotation.Scope;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 import org.springframework.security.access.AccessDeniedException;
 import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
 
 import java.util.Objects;
 
-@ControllerAdvice
+@RestControllerAdvice
 @Slf4j
-@Scope("singleton")
 public class GlobalExceptionHandler {
     /**
      * 方法参数校验
      */
     @ExceptionHandler(MethodArgumentNotValidException.class)
-    @ResponseBody
     public ResponseBodyVO<Object> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
         log.error(e.getMessage(), e);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage());
@@ -30,7 +28,6 @@ public class GlobalExceptionHandler {
      * 请求体缺失异常统一处理
      */
     @ExceptionHandler(HttpMessageNotReadableException.class)
-    @ResponseBody
     public ResponseBodyVO<Object> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
         log.error(e.getMessage(), e);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "Required request body is missing!");
@@ -41,7 +38,6 @@ public class GlobalExceptionHandler {
      * 权限校验异常统一处理
      */
     @ExceptionHandler(AccessDeniedException.class)
-    @ResponseBody
     public ResponseBodyVO<Object> handleAccessDeniedException(AccessDeniedException e) {
         log.error(e.getMessage(), e);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "Access is denied!");