Browse Source

后台元数据

“zhifk” 2 years ago
parent
commit
2dd81cdc82

+ 27 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/MetadataController.java

@@ -52,7 +52,11 @@ public class MetadataController extends BladeController {
     @ApiOperationSupport(order = 3)
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "逻辑删除", notes = "传入ids")
     @ApiOperation(value = "逻辑删除", notes = "传入ids")
     public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
     public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-        return R.status(iMetadataClassificationService.deleteLogic(Func.toLongList(ids)));
+        boolean b = iMetadataClassificationService.deleteLogic(Func.toLongList(ids));
+        if(b){
+            return R.status(iMetadataClassificationService.deleteTableField(Func.toLongList(ids).get(0)));
+        }
+        return R.status(false);
     }
     }
 
 
     /**
     /**
@@ -64,12 +68,32 @@ public class MetadataController extends BladeController {
     public R allocation(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@RequestParam String type) {
     public R allocation(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@RequestParam String type) {
         return R.status(iMetadataClassificationService.updateMetadataBytype(Func.toLongList(ids),type));
         return R.status(iMetadataClassificationService.updateMetadataBytype(Func.toLongList(ids),type));
     }
     }
-
+    /**
+     * 取消捕获
+     */
+    @PostMapping("/cancelAllocation")
+    @ApiOperationSupport(order = 5)
+    @ApiOperation(value = "取消捕获", notes = "传入ids")
+    public R cancelAllocation(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@RequestParam String type) {
+        MetadataClassification byId = iMetadataClassificationService.getById(Func.toLongList(ids).get(0));
+        String[] split = byId.getFileStorageType().split(",");
+        StringBuffer str = new StringBuffer();
+        for(String s :split){
+            if(s.equals(type)){
+                continue;
+            }
+            str.append(s+",");
+        }
+        String substring = str.toString().substring(0, str.lastIndexOf(","));
+        byId.setFileStorageType(substring);
+        iMetadataClassificationService.updateById(byId);
+        return R.status(iMetadataClassificationService.updateById(byId));
+    }
     /**
     /**
      * 查看没有设置当前分类的元数据容器
      * 查看没有设置当前分类的元数据容器
      */
      */
     @GetMapping("/allocation/detail")
     @GetMapping("/allocation/detail")
-    @ApiOperationSupport(order = 5)
+    @ApiOperationSupport(order = 6)
     @ApiOperation(value = "元数据容器分类详情", notes = "传入分类类型")
     @ApiOperation(value = "元数据容器分类详情", notes = "传入分类类型")
     public R<IPage<MetadataClassification>> allocationDetail(@ApiIgnore @RequestParam String fileStorage, Query query) {
     public R<IPage<MetadataClassification>> allocationDetail(@ApiIgnore @RequestParam String fileStorage, Query query) {
         QueryWrapper<MetadataClassification> metadata = new QueryWrapper<>();
         QueryWrapper<MetadataClassification> metadata = new QueryWrapper<>();

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/MetadataClassificationMapper.java

@@ -17,4 +17,7 @@ public interface MetadataClassificationMapper extends BaseMapper<MetadataClassif
     MetadataClassification selectMetadaOne(@Param("containerName") String containerName,@Param("code") String code,@Param("fieldKey") String fieldKey,@Param("id") Long id);
     MetadataClassification selectMetadaOne(@Param("containerName") String containerName,@Param("code") String code,@Param("fieldKey") String fieldKey,@Param("id") Long id);
 
 
     void updateMetadataBytype(@Param("ids") List<Long> ids, @Param("type") String type);
     void updateMetadataBytype(@Param("ids") List<Long> ids, @Param("type") String type);
+
+
+    void deleteTableField(@Param("containerInitTabName") String containerInitTabName,@Param("fieldKey") String fieldKey);
 }
 }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/MetadataClassificationMapper.xml

@@ -38,7 +38,7 @@
 
 
 
 
     <update id="deleteTableField">
     <update id="deleteTableField">
-        alter table ${tabName} drop column ${fieldName}
+        alter table ${containerInitTabName} drop column ${fieldKey}
     </update>
     </update>
 
 
     <update id="updateData">
     <update id="updateData">

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IMetadataClassificationService.java

@@ -14,4 +14,6 @@ public interface IMetadataClassificationService extends BaseService<MetadataClas
     boolean classificationSubmit(MetadataClassification obj);
     boolean classificationSubmit(MetadataClassification obj);
 
 
     boolean updateMetadataBytype(List<Long> ids,String type);
     boolean updateMetadataBytype(List<Long> ids,String type);
+
+    boolean deleteTableField(Long ids);
 }
 }

+ 13 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/MetadataClassificationServiceImpl.java

@@ -65,7 +65,7 @@ public class MetadataClassificationServiceImpl
             }else{
             }else{
                 MetadataClassification metadataClassification = baseMapper.selectMetadaOne(obj.getContainerName(), obj.getCode(),
                 MetadataClassification metadataClassification = baseMapper.selectMetadaOne(obj.getContainerName(), obj.getCode(),
                         "file_key_" + obj.getCode().toLowerCase(),obj.getId());
                         "file_key_" + obj.getCode().toLowerCase(),obj.getId());
-                if(metadataClassification != null){
+                if(metadataClassification == null){
                     return false;
                     return false;
                 }
                 }
                 String filetype = "varchar";
                 String filetype = "varchar";
@@ -98,4 +98,16 @@ public class MetadataClassificationServiceImpl
         }
         }
         return true;
         return true;
     }
     }
+
+    @Override
+    public boolean deleteTableField(Long ids) {
+        try {
+            MetadataClassification metadataClassification = baseMapper.selectById(ids);
+            baseMapper.deleteTableField(metadataClassification.getContainerInitTabName(),metadataClassification.getFieldKey());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
 }
 }