Преглед на файлове

feat(adm-diagram): 取消跨域配置

liyang преди 2 години
родител
ревизия
82c8cd16b4

+ 38 - 39
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/CommonController.java

@@ -11,7 +11,6 @@ import com.persagy.dmp.common.utils.ResultHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -21,55 +20,55 @@ import java.util.Map;
 
 /**
  * 公共接口
+ *
  * @author zhaoyk
  * @date 2021-12-27
  */
 @RestController
-@CrossOrigin
 public class CommonController {
 
-	@Autowired
-	private BdtpDataService bdtpDataService;
+    @Autowired
+    private BdtpDataService bdtpDataService;
 
-	@Autowired
-	@Qualifier(DataStrategy.IMPL_QUALIFIER)
-	private DataStrategy dataStrategy;
+    @Autowired
+    @Qualifier(DataStrategy.IMPL_QUALIFIER)
+    private DataStrategy dataStrategy;
 
-	@GetMapping("equipTypes")
-	public CommonResult<List<ObjectNode>> equipTypes(){
-		return ResultHelper.single(bdtpDataService.getEquipTypeList(BdtpRequest.getCurrent(), null));
-	}
+    @GetMapping("equipTypes")
+    public CommonResult<List<ObjectNode>> equipTypes() {
+        return ResultHelper.single(bdtpDataService.getEquipTypeList(BdtpRequest.getCurrent(), null));
+    }
 
-	@GetMapping("relTypes")
-	public CommonResult<List<Map<String, Object>>> relTypes(){
-		return ResultHelper.single(bdtpDataService.getRelTypeTree(BdtpRequest.getCurrent()));
-	}
+    @GetMapping("relTypes")
+    public CommonResult<List<Map<String, Object>>> relTypes() {
+        return ResultHelper.single(bdtpDataService.getRelTypeTree(BdtpRequest.getCurrent()));
+    }
 
-	@GetMapping("majSys")
-	public CommonResult<List<ObjectNode>> majSys(){
-		BdtpRequest req = BdtpRequest.getCurrent();
-		List<ObjectNode> majList = bdtpDataService.getMajorList(req);
-		List<ObjectNode> sysList = bdtpDataService.getSystemList(req);
+    @GetMapping("majSys")
+    public CommonResult<List<ObjectNode>> majSys() {
+        BdtpRequest req = BdtpRequest.getCurrent();
+        List<ObjectNode> majList = bdtpDataService.getMajorList(req);
+        List<ObjectNode> sysList = bdtpDataService.getSystemList(req);
 
-		for(ObjectNode maj : majList){
-			ArrayNode childrenSys = maj.putArray("children");
-			String majorCode = maj.get("code").asText();
-			maj.put("name", maj.get("label").asText());
-			for(Iterator<ObjectNode> sysIter = sysList.iterator(); sysIter.hasNext();){
-				ObjectNode sys = sysIter.next();
-				if(sys.get("majorCode") != null && sys.get("majorCode").asText().equals(majorCode)){
-					childrenSys.add(sys);
-					sysIter.remove();
-				}
-			}
-		}
-		return ResultHelper.single(majList);
-	}
+        for (ObjectNode maj : majList) {
+            ArrayNode childrenSys = maj.putArray("children");
+            String majorCode = maj.get("code").asText();
+            maj.put("name", maj.get("label").asText());
+            for (Iterator<ObjectNode> sysIter = sysList.iterator(); sysIter.hasNext(); ) {
+                ObjectNode sys = sysIter.next();
+                if (sys.get("majorCode") != null && sys.get("majorCode").asText().equals(majorCode)) {
+                    childrenSys.add(sys);
+                    sysIter.remove();
+                }
+            }
+        }
+        return ResultHelper.single(majList);
+    }
 
-	@ApiOperation("查询系统图类型列表")
-	@GetMapping("diagramTypes")
-	public CommonResult<List<DiagramType>> diagramTypes(){
-		return ResultHelper.single(dataStrategy.getDiagramTypes());
-	}
+    @ApiOperation("查询系统图类型列表")
+    @GetMapping("diagramTypes")
+    public CommonResult<List<DiagramType>> diagramTypes() {
+        return ResultHelper.single(dataStrategy.getDiagramTypes());
+    }
 
 }

+ 80 - 70
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/DemoDiagramController.java

@@ -1,95 +1,105 @@
 package com.persagy.adm.diagram.controller;
 
+import com.persagy.adm.diagram.core.model.Diagram;
 import com.persagy.adm.diagram.frame.EditRequest;
 import com.persagy.adm.diagram.manage.DemoDiagramManager;
 import com.persagy.adm.diagram.manage.Folder;
-import com.persagy.adm.diagram.core.model.Diagram;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.Map;
 
 @RestController
-@CrossOrigin
 @RequestMapping("diagram0")
 public class DemoDiagramController {
 
-	@Autowired
-	private DemoDiagramManager diagramManager;
+    @Autowired
+    private DemoDiagramManager diagramManager;
 
-	/**
-	 * 查询系统图
-	 * @param projectId 项目id
-	 * @param systemId 系统实例id
-	 * @param groupCode 集团编码
-	 * @return 树形结构数据(专业-系统-类型-图)
-	 */
-	@ApiOperation("查询系统图,返回树形结构")
-	@GetMapping("getDiagrams")
-	public CommonResult<List<Folder>> getDiagrams(@RequestParam String projectId,
-												  @RequestParam(required = false) String systemId,
-												  @RequestParam(required = false) String groupCode){
-		return ResultHelper.single(diagramManager.getDiagrams(projectId, systemId, groupCode));
-	}
+    /**
+     * 查询系统图
+     *
+     * @param projectId 项目id
+     * @param systemId  系统实例id
+     * @param groupCode 集团编码
+     * @return 树形结构数据(专业 - 系统 - 类型 - 图)
+     */
+    @ApiOperation("查询系统图,返回树形结构")
+    @GetMapping("getDiagrams")
+    public CommonResult<List<Folder>> getDiagrams(@RequestParam String projectId,
+                                                  @RequestParam(required = false) String systemId,
+                                                  @RequestParam(required = false) String groupCode) {
+        return ResultHelper.single(diagramManager.getDiagrams(projectId, systemId, groupCode));
+    }
 
-	/**
-	 * 新建系统图
-	 * @param params 新建参数,对象类型,包含字段 name:名称, type:系统图类型编码
-	 * @param projectId 项目id
-	 * @param systemId 系统实例id
-	 * @param groupCode 集团编码
-	 * @return 新建的系统图对象
-	 */
-	@PostMapping("newDiagram")
-	public CommonResult<Diagram> newDiagram(@RequestBody Map<String, String> params,
-											@RequestParam String projectId,
-											@RequestParam(required = false) String systemId,
-											@RequestParam(required = false) String groupCode){
-		return ResultHelper.single(diagramManager.createDiagram(params.get("name"), params.get("type"), projectId, systemId, groupCode));
-	}
+    /**
+     * 新建系统图
+     *
+     * @param params    新建参数,对象类型,包含字段 name:名称, type:系统图类型编码
+     * @param projectId 项目id
+     * @param systemId  系统实例id
+     * @param groupCode 集团编码
+     * @return 新建的系统图对象
+     */
+    @PostMapping("newDiagram")
+    public CommonResult<Diagram> newDiagram(@RequestBody Map<String, String> params,
+                                            @RequestParam String projectId,
+                                            @RequestParam(required = false) String systemId,
+                                            @RequestParam(required = false) String groupCode) {
+        return ResultHelper.single(diagramManager.createDiagram(params.get("name"), params.get("type"), projectId, systemId, groupCode));
+    }
 
-	/**
-	 * 删除系统图
-	 * @param params 删除参数,对象类型,包含字段 id:系统图id
-	 * @return
-	 */
-	@PostMapping("delDiagram")
-	public CommonResult<Boolean> delDiagram(@RequestBody Map<String, String> params){
-		return ResultHelper.single(diagramManager.deleteDiagram(params.get("id")));
-	}
+    /**
+     * 删除系统图
+     *
+     * @param params 删除参数,对象类型,包含字段 id:系统图id
+     * @return
+     */
+    @PostMapping("delDiagram")
+    public CommonResult<Boolean> delDiagram(@RequestBody Map<String, String> params) {
+        return ResultHelper.single(diagramManager.deleteDiagram(params.get("id")));
+    }
 
-	/**
-	 * 设置(修改)系统图使用的模板
-	 * @param req 编辑参数,对象类型,包含字段 diagramId:系统图id, templateId:使用的模板id
-	 * @return 系统图对象
-	 */
-	@PostMapping("setTemplate")
-	public CommonResult<Diagram> setTemplate(@RequestBody EditRequest req){
-		return ResultHelper.single(diagramManager.setTemplate(req.getDiagramId(), req.getTemplateId()));
-	}
+    /**
+     * 设置(修改)系统图使用的模板
+     *
+     * @param req 编辑参数,对象类型,包含字段 diagramId:系统图id, templateId:使用的模板id
+     * @return 系统图对象
+     */
+    @PostMapping("setTemplate")
+    public CommonResult<Diagram> setTemplate(@RequestBody EditRequest req) {
+        return ResultHelper.single(diagramManager.setTemplate(req.getDiagramId(), req.getTemplateId()));
+    }
 
-	/**
-	 * 自动加载数据
-	 * @param req 编辑参数,对象类型,包含字段 diagramId:系统图id
-	 * @return 系统图对象
-	 */
-	@PostMapping("loadData")
-	public CommonResult<Diagram> loadData(@RequestBody EditRequest req) {
-		return ResultHelper.single(diagramManager.loadData(req.getDiagramId(), true));
-	}
+    /**
+     * 自动加载数据
+     *
+     * @param req 编辑参数,对象类型,包含字段 diagramId:系统图id
+     * @return 系统图对象
+     */
+    @PostMapping("loadData")
+    public CommonResult<Diagram> loadData(@RequestBody EditRequest req) {
+        return ResultHelper.single(diagramManager.loadData(req.getDiagramId(), true));
+    }
 
-	/**
-	 * 保存系统图
-	 * @param req 编辑参数,对象类型,包含字段 diagram:系统图对象
-	 * @return 保存后的系统图对象
-	 */
-	@PostMapping("saveDiagram")
-	public CommonResult<Diagram> saveDiagram(@RequestBody EditRequest req) {
-		return ResultHelper.single(diagramManager.saveDiagram(req.getDiagram()));
-	}
+    /**
+     * 保存系统图
+     *
+     * @param req 编辑参数,对象类型,包含字段 diagram:系统图对象
+     * @return 保存后的系统图对象
+     */
+    @PostMapping("saveDiagram")
+    public CommonResult<Diagram> saveDiagram(@RequestBody EditRequest req) {
+        return ResultHelper.single(diagramManager.saveDiagram(req.getDiagram()));
+    }
 
 }

+ 0 - 2
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/DiagramController.java

@@ -21,7 +21,6 @@ import com.persagy.dmp.common.utils.ResultHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -42,7 +41,6 @@ import java.util.Optional;
  * @date 2022-01-04
  */
 @RestController
-@CrossOrigin
 @RequestMapping("/diagram")
 public class DiagramController {
 

+ 0 - 2
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/IconController.java

@@ -14,7 +14,6 @@ import com.persagy.dmp.file.model.FileInfoCreator;
 import com.persagy.dmp.file.utils.FileStorageHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +36,6 @@ import java.util.Optional;
  * @date 2022-01-06
  */
 @RestController
-@CrossOrigin
 @RequestMapping("/icon")
 public class IconController {
 

+ 26 - 22
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/LegendController.java

@@ -1,48 +1,52 @@
 package com.persagy.adm.diagram.controller;
 
-import com.persagy.adm.diagram.frame.EditRequest;
 import com.persagy.adm.diagram.core.model.legend.Legend;
+import com.persagy.adm.diagram.frame.EditRequest;
 import com.persagy.adm.diagram.manage.LegendManager;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 
 @RestController
-@CrossOrigin
 @RequestMapping("legend")
 public class LegendController {
 
-	@Autowired
-	private LegendManager legendManager;
+    @Autowired
+    private LegendManager legendManager;
 
-	@ApiOperation("按照系统代码,查询图例列表")
-	@GetMapping("getLegends")
-	public CommonResult<List<Legend>> getLegends(@RequestParam String sys){
-		return ResultHelper.single(legendManager.getLegends(sys));
-	}
+    @ApiOperation("按照系统代码,查询图例列表")
+    @GetMapping("getLegends")
+    public CommonResult<List<Legend>> getLegends(@RequestParam String sys) {
+        return ResultHelper.single(legendManager.getLegends(sys));
+    }
 
-	@PostMapping("saveLegend")
-	public CommonResult<Legend> saveLegend(@RequestBody EditRequest req){
-		return ResultHelper.single(legendManager.saveLegend(req.getLegend(), req.getSys()));
-	}
+    @PostMapping("saveLegend")
+    public CommonResult<Legend> saveLegend(@RequestBody EditRequest req) {
+        return ResultHelper.single(legendManager.saveLegend(req.getLegend(), req.getSys()));
+    }
 
-	@PostMapping("delLegend")
-	public CommonResult<Boolean> delLegend(@RequestBody EditRequest req){
-		return ResultHelper.single(legendManager.deleteLegend(req.getCurrentCompId(), req.getSys()));
-	}
+    @PostMapping("delLegend")
+    public CommonResult<Boolean> delLegend(@RequestBody EditRequest req) {
+        return ResultHelper.single(legendManager.deleteLegend(req.getCurrentCompId(), req.getSys()));
+    }
 
 //	@RequestMapping("fixRel")
 //	public CommonResult<Boolean> fixRel(){
 //		return ResultHelper.single(legendManager.fixRel());
 //	}
 
-	@RequestMapping("fixDiagramType")
-	public CommonResult<Boolean> fixDiagramType(){
-		return ResultHelper.single(legendManager.fixDiagramType());
-	}
+    @RequestMapping("fixDiagramType")
+    public CommonResult<Boolean> fixDiagramType() {
+        return ResultHelper.single(legendManager.fixDiagramType());
+    }
 
 }

+ 21 - 17
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/TemplateController.java

@@ -8,13 +8,17 @@ import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.Map;
 
 @RestController
-@CrossOrigin
 @RequestMapping("template")
 public class TemplateController {
 
@@ -23,63 +27,63 @@ public class TemplateController {
 
     @ApiOperation("查询模板列表")
     @GetMapping("getTemplates")
-    public CommonResult<List<Folder>> getTemplates(){
+    public CommonResult<List<Folder>> getTemplates() {
         return ResultHelper.single(templateManager.getTemplates());
     }
 
     @ApiOperation("按系统图类型查询模板列表")
     @GetMapping("getTemplatesByType")
-    public CommonResult<List<DiagramTemplate>> getTemplatesByType(@RequestParam String diagramType){
+    public CommonResult<List<DiagramTemplate>> getTemplatesByType(@RequestParam String diagramType) {
         return ResultHelper.single(templateManager.getTemplates(diagramType));
     }
 
     @PostMapping("newTemplate")
-    public CommonResult<DiagramTemplate> newTemplate(@RequestBody Map<String, String> params){
+    public CommonResult<DiagramTemplate> newTemplate(@RequestBody Map<String, String> params) {
         return ResultHelper.single(templateManager.createTemplate(params.get("name"), params.get("type")));
     }
 
     @PostMapping("delTemplate")
-    public CommonResult<Boolean> delTemplate(@RequestBody Map<String, String> params){
+    public CommonResult<Boolean> delTemplate(@RequestBody Map<String, String> params) {
         return ResultHelper.single(templateManager.deleteTemplate(params.get("id")));
     }
 
     @PostMapping("editTemplateInfo")
-    public CommonResult<Boolean> editTemplateInfo(@RequestBody Map<String, String> params){
+    public CommonResult<Boolean> editTemplateInfo(@RequestBody Map<String, String> params) {
         return ResultHelper.single(templateManager.editTemplateInfo(params.remove("id"), params));
     }
 
     @PostMapping("addCon")
-    public CommonResult<DiagramTemplate> addCon(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> addCon(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.addCon(params.getNewCompId(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
     @PostMapping("delCon")
-    public CommonResult<DiagramTemplate> delCon(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> delCon(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.delCon(params.getCurrentCompId(), params.getTemplateId()));
     }
 
     @PostMapping("moveCon")
-    public CommonResult<DiagramTemplate> moveCon(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> moveCon(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.moveCon(params.getCurrentCompId(), params.getTemplateId(), params.getMoveOffset()));
     }
 
     @PostMapping("addMainPipe")
-    public CommonResult<DiagramTemplate> addMainPipe(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> addMainPipe(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.addMainPipe(params.getLines(), params.getTemplateId()));
     }
 
     @PostMapping("delLine")
-    public CommonResult<DiagramTemplate> delLine(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> delLine(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.delMainPipe(params.getCurrentCompId(), params.getTemplateId()));
     }
 
     @PostMapping("modifyCon")
-    public CommonResult<DiagramTemplate> modifyCon(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> modifyCon(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.modifyCon(params.getTemplatePropsData(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
     @PostMapping("modifyMainPipe")
-    public CommonResult<DiagramTemplate> modifyMainPipe(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> modifyMainPipe(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.modifyMainPipe(params.getTemplatePropsData(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
@@ -87,7 +91,7 @@ public class TemplateController {
      * 编辑设备过滤条件
      */
     @PostMapping("modifyFilter")
-    public CommonResult<DiagramTemplate> modifyFilter(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> modifyFilter(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.modifyFilter(params.getDataFilter(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
@@ -95,7 +99,7 @@ public class TemplateController {
      * 编辑设备打包配置
      */
     @PostMapping("modifyPack")
-    public CommonResult<DiagramTemplate> modifyPack(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> modifyPack(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.modifyPack(params.getEquipPack(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
@@ -103,7 +107,7 @@ public class TemplateController {
      * 编辑容器的动态组配置
      */
     @PostMapping("modifyDynGroup")
-    public CommonResult<DiagramTemplate> modifyDynGroup(@RequestBody EditRequest params){
+    public CommonResult<DiagramTemplate> modifyDynGroup(@RequestBody EditRequest params) {
         return ResultHelper.single(templateManager.modifyDynGroup(params.getDynGroup(), params.getCurrentCompId(), params.getTemplateId()));
     }