浏览代码

实现/rel-manual-calc/del接口

lijie 3 年之前
父节点
当前提交
6fe283c591

+ 17 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmManualRelCalController.java

@@ -1,12 +1,14 @@
 package com.persagy.proxy.adm.controller;
 
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmManualRelationCalcDel;
 import com.persagy.proxy.adm.model.AdmRelationAddRequest;
 import com.persagy.proxy.adm.request.AdmCreateResponse;
 import com.persagy.proxy.adm.service.AdmManualRelCalService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -44,6 +46,21 @@ public class AdmManualRelCalController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         return admManualRelationCalcService.addRels(context,request);
     }
+    /***
+     * Description: 删除关系
+     * @param admManualRelationCalcDel : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
+     * @author : lijie
+     * @date :2021/8/31 12:10
+     * Update By lijie 2021/8/31 12:10
+     */
+    @PostMapping(value = "del")
+    public AdmCreateResponse delRels(@QueryParam("projectId") String projectId,
+                                     @Validated @RequestBody AdmManualRelationCalcDel admManualRelationCalcDel) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return admManualRelationCalcService.delRels(context,admManualRelationCalcDel);
+    }
 
 
 

+ 26 - 0
src/main/java/com/persagy/proxy/adm/model/AdmManualRelationCalcDel.java

@@ -0,0 +1,26 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class AdmManualRelationCalcDel {
+
+    /**主对象Id*/
+    @NotNull(message = "主对象 id 不可以为空")
+    private String fromId;
+
+    /**从对象 Id*/
+    @NotNull(message = "从对象 id 不可以为空")
+    private String toId;
+
+    /**关系类型*/
+    @NotNull(message = "关系类型不可以为空")
+    String relType;
+
+    /**图类型*/
+    @NotNull(message = "图类型不可以为空")
+    String graphicType;
+
+}

+ 10 - 0
src/main/java/com/persagy/proxy/adm/service/AdmManualRelCalService.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.service;
 
+import com.persagy.proxy.adm.model.AdmManualRelationCalcDel;
 import com.persagy.proxy.adm.model.AdmRelationAddRequest;
 import com.persagy.proxy.adm.request.AdmCreateResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -22,4 +23,13 @@ public interface AdmManualRelCalService {
      * Update By lijie 2021/8/31 12:14
      */
     AdmCreateResponse addRels(InstanceUrlParam context, AdmRelationAddRequest request);
+    /***
+     * Description: 删除关系
+     * @param admManualRelationCalcDel : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
+     * @author : lijie
+     * @date :2021/8/31 12:10
+     * Update By lijie 2021/8/31 12:10
+     */
+    AdmCreateResponse delRels(InstanceUrlParam context, AdmManualRelationCalcDel admManualRelationCalcDel);
 }

+ 28 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmManualRelCalServiceImpl.java

@@ -9,6 +9,7 @@ import com.persagy.dmp.digital.client.DigitalRelationCaclClient;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
 import com.persagy.proxy.adm.constant.BusinessErrorRwdCode;
+import com.persagy.proxy.adm.model.AdmManualRelationCalcDel;
 import com.persagy.proxy.adm.model.AdmRelationAddRequest;
 import com.persagy.proxy.adm.request.AdmCreateResponse;
 import com.persagy.proxy.adm.service.AdmManualRelCalService;
@@ -271,4 +272,31 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
         // sp2bd_ArchForArch,sp2fl_ArchForArch,sp2sh_ArchForArch,sp2sp_ArchForArch
 
     }
+    /***
+     * Description: 删除关系
+     * @param admManualRelationCalcDel : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
+     * @author : lijie
+     * @date :2021/8/31 12:10
+     * Update By lijie 2021/8/31 12:10
+     */
+    @Override
+    public AdmCreateResponse delRels(InstanceUrlParam context, AdmManualRelationCalcDel admManualRelationCalcDel) {
+        ObjectRelation objectRelation = new ObjectRelation();
+        Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
+        if (relationTypeMap.containsKey(admManualRelationCalcDel.getRelType())){
+            return AdmCreateResponse.failure("不存在的关系类型");
+        }
+        AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(admManualRelationCalcDel.getRelType());
+        objectRelation.setGraphCode(relationTypeEnum.getGraphCode());
+        objectRelation.setRelCode(relationTypeEnum.getRelCode());
+        objectRelation.setObjFrom(admManualRelationCalcDel.getFromId());
+        objectRelation.setObjTo(admManualRelationCalcDel.getToId());
+        CommonResult<List<ObjectRelation>> commonResult = digitalRelationCaclClient.deleteObjRelationsByRelId(context.getGroupCode(),
+                context.getProjectId(), context.getAppId(), "0", objectRelation);
+        if (!"success".equals(commonResult.getResult())){
+            return AdmCreateResponse.failure(commonResult.getMessage());
+        }
+        return AdmCreateResponse.success("删除关系成功");
+    }
 }