Browse Source

优化:去掉文件服务接口的跨域设置,改为由nginx统一控制

lijie 2 years ago
parent
commit
6ba1d6baf1

+ 0 - 4
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/controller/FileController.java

@@ -121,7 +121,6 @@ public class FileController {
      * Update By lijie 2021/10/9 20:12
      */
     @PostMapping("/initChunkUpload")
-    @CrossOrigin(origins = "*",allowCredentials = "true",methods = {RequestMethod.POST,RequestMethod.GET},maxAge = 3600)
     public CommonResult<UploadMes> initChunkUpload(@RequestBody FileRequestData requestData) {
         // 1.兼容一下groupCode
         fillGroupCode(requestData);
@@ -144,7 +143,6 @@ public class FileController {
      * Update By lijie 2021/10/9 20:12
      */
     @PostMapping("/composeFile")
-    @CrossOrigin(origins = "*",allowCredentials = "true",methods = {RequestMethod.POST,RequestMethod.GET},maxAge = 3600)
     public CommonResult<FileInfo> composeFile(@RequestBody FileRequestData requestData) {
         //基础参数校验
         // 1.兼容一下groupCode
@@ -167,7 +165,6 @@ public class FileController {
      * Update By lijie 2021/10/9 20:12
      */
     @PostMapping("/initSingleUpload")
-    @CrossOrigin(origins = "*",allowCredentials = "true",methods = {RequestMethod.POST,RequestMethod.GET},maxAge = 3600)
     public CommonResult<UploadMes> initSingleUpload(@RequestBody FileRequestData requestData) {
         //基础参数校验
         // 1.兼容一下groupCode
@@ -190,7 +187,6 @@ public class FileController {
      * Update By lijie 2021/10/9 20:12
      */
     @PostMapping("/initFileDownload")
-    @CrossOrigin(origins = "*",allowCredentials = "true",methods = {RequestMethod.POST,RequestMethod.GET},maxAge = 3600)
     public CommonResult<FileInfo> initFileDownload(@RequestBody FileRequestData requestData) {
         //基础参数校验
         if(StrUtil.isBlank(requestData.getFileId())) {

+ 1 - 1
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/digital/client/DigitalObjectClient.java

@@ -73,7 +73,7 @@ public interface DigitalObjectClient {
                                          @RequestParam("projectId") String projectId,
                                          @RequestParam("appId") String appId,
                                          @RequestParam("userId") String userId,
-                                         @RequestBody QueryCriteria criteria);
+                                         @RequestBody Object criteria);
     /**
      * 新增物理世界对象-单个新增
      * @param groupCode: 集团编码

+ 32 - 0
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/digital/client/DigitalObjectFacade.java

@@ -1,16 +1,20 @@
 package com.persagy.dmp.digital.client;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
+import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import com.persagy.dmp.digital.entity.ObjectDigital;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
@@ -109,6 +113,34 @@ public class DigitalObjectFacade {
         return client.query(groupCode, projectId, appId, userId, criteria);
     }
     /**
+     * 查询物理世界对象
+     * @param groupCode: 集团编码
+     * @param projectId: 项目ID
+     * @param appId: 应用ID
+     * @param userId: 用户ID
+     * @param criteria: 请求参数
+     * @return 原样查询结果
+     */
+    public static CommonResult<List<ObjectDigital>> queryObject(String groupCode, String projectId, String appId,
+                                                       String userId, Object criteria) {
+        CommonResult<List<ObjectNode>> commonResult = client.query(groupCode, projectId, appId, userId, criteria);
+        if (!CommonConstant.QUERY_SUCCESS.equals(commonResult.getResult())){
+            return ResultHelper.failure(commonResult.getResult(),commonResult.getMessage());
+        }
+        if (CollUtil.isEmpty(commonResult.getData())){
+            // 数据为空或者只查询数量
+            return ResultHelper.multi(new ArrayList<>(),commonResult.getCount());
+        }
+        // 转换为对象
+        List<ObjectNode> resultData = commonResult.getData();
+        ArrayNode arrayNode = JsonNodeUtils.toArrayNode(resultData, ObjectDigital.EXTRA_COLUMN, null);
+        if(null==arrayNode){
+            // 数据为空或者只查询数量
+            return ResultHelper.multi(new ArrayList<>(),commonResult.getCount());
+        }
+        return ResultHelper.multi(JsonNodeUtils.toEntity(arrayNode,ObjectDigital.class,ObjectDigital.EXTRA_COLUMN),commonResult.getCount());
+    }
+    /**
      * 新增物理世界对象-单个新增
      * @param groupCode: 集团编码
      * @param projectId: 项目ID