Bläddra i källkod

feat(adm-diagram): 新增判断系统图名称是否重复接口(项目维度下)

liyang 2 år sedan
förälder
incheckning
bcb641268b

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

@@ -303,4 +303,15 @@ public class DiagramController {
     public CommonResult<Map<String, Boolean>> querySystemInstanceDiagramList() {
         return ResultHelper.single(dataStrategy.querySystemInstanceDiagramList());
     }
+
+    /**
+     * 判断系统图名称是否重复  true:重复,false:不重复
+     *
+     * @return 是否成功
+     */
+    @ApiOperation("判断系统图名称是否重复")
+    @PostMapping("/judge/name/duplicate")
+    public CommonResult<Boolean> judgeNameDuplicate(@RequestBody Map<String, String> params) {
+        return ResultHelper.single(dataStrategy.judgeNameDuplicate(params.get("name")));
+    }
 }

+ 8 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DataStrategy.java

@@ -248,4 +248,12 @@ public interface DataStrategy {
      * @return 是否成功
      */
     boolean updateName(String name, String id);
+
+    /**
+     * 判断系统图名称是否重复
+     *
+     * @param name 系统图名称
+     * @return 是否重复
+     */
+    boolean judgeNameDuplicate(String name);
 }

+ 17 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/impl/DataStrategyImpl.java

@@ -715,4 +715,21 @@ public class DataStrategyImpl implements DataStrategy {
         diagramMapper.updateById(entity);
         return true;
     }
+
+    /**
+     * 判断系统图名称是否重复
+     *
+     * @param name 系统图名称
+     * @return 是否重复
+     */
+    @Override
+    public boolean judgeNameDuplicate(String name) {
+        if (StrUtil.isBlank(name)) {
+            throw new BusinessException(ResponseCode.A0400.getCode(), "名称参数为空");
+        }
+        BdtpRequest req = BdtpRequest.getCurrent();
+        String projectId = req.getProjectId();
+        List<DiagramEntity> diagramEntities = diagramMapper.selectByName(projectId, name);
+        return CollectionUtil.isNotEmpty(diagramEntities);
+    }
 }

+ 8 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/dao/DiagramMapper.java

@@ -64,4 +64,12 @@ public interface DiagramMapper extends BaseMapper<DiagramEntity> {
      */
     DiagramEntity getDiagram(String diagramId);
 
+    /**
+     * 判断系统图名称是否重复
+     *
+     * @param projectId 项目id
+     * @param name      系统图名称
+     * @return 是否重复
+     */
+    List<DiagramEntity> selectByName( String projectId, String name);
 }

+ 5 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/demo/DemoDataStrategy.java

@@ -423,4 +423,9 @@ public class DemoDataStrategy implements DataStrategy {
     public boolean updateName(String name, String id) {
         return false;
     }
+
+    @Override
+    public boolean judgeNameDuplicate(String name) {
+        return false;
+    }
 }

+ 7 - 0
adm-business/adm-diagram/src/main/resources/mapper/Diagram.xml

@@ -87,6 +87,13 @@
         </if>
     </select>
 
+    <select id="selectByName" resultMap="diagramBaseMap">
+        SELECT
+        <include refid="baseSql"/>
+        FROM diagram
+        WHERE project_id=#{projectId} AND name=#{name} AND valid = 1
+    </select>
+
 </mapper>