Просмотр исходного кода

fix: 地图相关后端查重接口优化

地图相关后端查重接口优化
hong.yang 1 год назад
Родитель
Сommit
cd6dd0f769

+ 0 - 28
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/chart/components/CustomComponentChart.java

@@ -44,42 +44,14 @@ public class CustomComponentChart extends Chart {
     @ApiModelProperty(notes = "组件的唯一名称")
     private String name;
 
-
     @Data
     public static class Setting {
 
-        @ApiModelProperty(notes = "配置项名称")
-        private String label;
-
-        @ApiModelProperty(notes = "配置项组件类型")
-        private String type;
-
         @ApiModelProperty(notes = "配置项字段")
         private String field;
 
-        @ApiModelProperty(notes = "配置项对应options中的字段")
-        private String optionField;
-
-        @ApiModelProperty(notes = "是否多选")
-        private Boolean multiple;
-
         @ApiModelProperty(notes = "值")
         private Object value;
-
-        @ApiModelProperty(notes = "所属tab页")
-        private String tabName;
-
-        @ApiModelProperty(notes = "多选时选项")
-        private Object options;
-
-        @ApiModelProperty(notes = "步长")
-        private Integer step;
-
-        @ApiModelProperty(notes = "所属样式分组")
-        private String groupName;
-
     }
 
-
-
 }

+ 15 - 7
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/map/controller/DataRoomMapController.java

@@ -66,9 +66,9 @@ public class DataRoomMapController {
     @ApiPermission(permissions = {Permission.Map.DELETE})
     @PostMapping("/delete/{id}")
     @ApiOperation(value = "删除", position = 40, notes = "删除地图数据", produces = MediaType.APPLICATION_JSON_VALUE)
-    public R<Void> delete(@PathVariable String id) {
-        dataRoomMapService.delete(id);
-        return R.success();
+    public R<Boolean> delete(@PathVariable String id) {
+        boolean delete = dataRoomMapService.delete(id);
+        return R.success(delete);
     }
 
     @ApiPermission(permissions = {Permission.Map.DELETE})
@@ -126,16 +126,24 @@ public class DataRoomMapController {
 
 
     @ApiPermission(permissions = {Permission.Map.VIEW})
-    @PostMapping("/repeat")
-    @ApiOperation(value = "重复", position = 100, notes = "地图数据重复校验", produces = MediaType.APPLICATION_JSON_VALUE)
+    @PostMapping("/repeat/code")
+    @ApiOperation(value = "编码重复校验", position = 100, notes = "地图数据重复校验", produces = MediaType.APPLICATION_JSON_VALUE)
     public R<Boolean> repeat(@RequestBody DataRoomMapRepeatDTO mapDTO) {
-        Boolean repeat = dataRoomMapService.repeatCheck(mapDTO);
+        Boolean repeat = dataRoomMapService.codeRepeatCheck(mapDTO);
+        return R.success(repeat);
+    }
+
+    @ApiPermission(permissions = {Permission.Map.VIEW})
+    @PostMapping("/repeat/name")
+    @ApiOperation(value = "名称重复校验", position = 110, notes = "地图数据重复校验", produces = MediaType.APPLICATION_JSON_VALUE)
+    public R<Boolean> repeatName(@RequestBody DataRoomMapRepeatDTO mapDTO) {
+        Boolean repeat = dataRoomMapService.nameRepeatCheck(mapDTO);
         return R.success(repeat);
     }
 
     @ApiPermission(permissions = {Permission.Map.VIEW})
     @GetMapping("/tree/{level}")
-    @ApiOperation(value = "树", position = 110, notes = "地图数据树", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "树", position = 120, notes = "地图数据树", produces = MediaType.APPLICATION_JSON_VALUE)
     public R<List<DataRoomMapVO>> tree(@PathVariable String level) {
         int levelInt = 0;
         try {

+ 2 - 0
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/map/dto/DataRoomMapRepeatDTO.java

@@ -20,4 +20,6 @@ public class DataRoomMapRepeatDTO {
     @ApiModelProperty(notes = "地图编码")
     private String mapCode;
 
+    @ApiModelProperty(notes = "地图名称")
+    private String mapName;
 }

+ 11 - 2
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/map/service/IDataRoomMapService.java

@@ -56,8 +56,9 @@ public interface IDataRoomMapService extends ISuperService<DataRoomMapEntity> {
     /**
      * 删除地图
      * @param id
+     * @return
      */
-    void delete(String id);
+    boolean delete(String id);
 
     /**
      * 级联删除地图,删除地图及其子地图...
@@ -110,6 +111,14 @@ public interface IDataRoomMapService extends ISuperService<DataRoomMapEntity> {
      * @param mapDTO
      * @return
      */
-    boolean repeatCheck(DataRoomMapRepeatDTO mapDTO);
+    boolean codeRepeatCheck(DataRoomMapRepeatDTO mapDTO);
+
 
+    /**
+     * 名称重复校验
+     * 只在相同的父级下校验
+     * @param mapDTO
+     * @return
+     */
+    boolean nameRepeatCheck(DataRoomMapRepeatDTO mapDTO);
 }

+ 32 - 8
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/map/service/impl/DataRoomMapServiceImpl.java

@@ -251,21 +251,22 @@ public class DataRoomMapServiceImpl extends ServiceImpl<DataRoomMapDao, DataRoom
 
 
     @Override
-    public void delete(String id) {
+    public boolean delete(String id) {
         if (StringUtils.isBlank(id)) {
-            return;
+            return true;
         }
         DataRoomMapEntity mapEntity = this.getById(id);
         if (mapEntity == null) {
-            return;
+            return true;
         }
         LambdaQueryWrapper<DataRoomMapEntity> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(DataRoomMapEntity::getParentId, mapEntity.getId());
         List<DataRoomMapEntity> list = this.list(queryWrapper);
         if (list != null && list.size() > 0) {
-            throw new GlobalException("该地图下存在子地图,不能删除");
+            return false;
         }
         this.removeById(id);
+        return true;
     }
 
 
@@ -360,10 +361,10 @@ public class DataRoomMapServiceImpl extends ServiceImpl<DataRoomMapDao, DataRoom
         }
         // 查询当前地图下的所有子地图
         LambdaQueryWrapper<DataRoomMapEntity> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.select(DataRoomMapEntity::getMapCode);
+        queryWrapper.select(DataRoomMapEntity::getMapCode, DataRoomMapEntity::getId);
         queryWrapper.eq(DataRoomMapEntity::getParentId, id);
         List<DataRoomMapEntity> list = this.list(queryWrapper);
-        List<String> mapCodeList = list.stream().map(DataRoomMapEntity::getMapCode).collect(Collectors.toList());
+        Map<String, String> codeIdMap = list.stream().collect(Collectors.toMap(DataRoomMapEntity::getMapCode, DataRoomMapEntity::getId));
         // 解析geoJson,获取下一级的基础数据
         List<MapChildVO> childList = Lists.newArrayList();
         for (int i = 0; i < features.length(); i++) {
@@ -375,7 +376,10 @@ public class DataRoomMapServiceImpl extends ServiceImpl<DataRoomMapDao, DataRoom
             String name = properties.getString("name");
             MapChildVO childVO = new MapChildVO();
             childVO.setName(name);
-            childVO.setExist(mapCodeList.contains(name));
+            childVO.setExist(codeIdMap.containsKey(name));
+            if (childVO.getExist()) {
+                childVO.setExistId(codeIdMap.get(name));
+            }
             childList.add(childVO);
         }
         return childList;
@@ -403,7 +407,7 @@ public class DataRoomMapServiceImpl extends ServiceImpl<DataRoomMapDao, DataRoom
     }
 
     @Override
-    public boolean repeatCheck(DataRoomMapRepeatDTO mapDTO) {
+    public boolean codeRepeatCheck(DataRoomMapRepeatDTO mapDTO) {
         if (StringUtils.isBlank(mapDTO.getMapCode())) {
             throw new GlobalException("地图编码不能为空");
         }
@@ -419,4 +423,24 @@ public class DataRoomMapServiceImpl extends ServiceImpl<DataRoomMapDao, DataRoom
         List<DataRoomMapEntity> list = this.list(queryWrapper);
         return list != null && list.size() > 0;
     }
+
+
+    @Override
+    public boolean nameRepeatCheck(DataRoomMapRepeatDTO mapDTO) {
+        if (StringUtils.isBlank(mapDTO.getMapName())) {
+            throw new GlobalException("地图名称不能为空");
+        }
+        if (StringUtils.isBlank(mapDTO.getParentId())) {
+            throw new GlobalException("上级地图编码不能为空");
+        }
+        LambdaQueryWrapper<DataRoomMapEntity> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(DataRoomMapEntity::getName, mapDTO.getMapName());
+        queryWrapper.eq(DataRoomMapEntity::getParentId, mapDTO.getParentId());
+        if (StringUtils.isNotBlank(mapDTO.getId())) {
+            queryWrapper.ne(DataRoomMapEntity::getId, mapDTO.getId());
+        }
+        List<DataRoomMapEntity> list = this.list(queryWrapper);
+        return list != null && list.size() > 0;
+
+    }
 }

+ 3 - 0
DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/module/map/vo/MapChildVO.java

@@ -17,4 +17,7 @@ public class MapChildVO {
     @ApiModelProperty(notes = "是否已存在")
     private Boolean exist;
 
+    @ApiModelProperty(notes = "已存在的地图id")
+    private String existId;
+
 }