Browse Source

添加
史料管理模块更新-添加删除接口

wuweihao 4 years ago
parent
commit
099e9cd94b

+ 2 - 0
gis_service/src/main/java/com/gis/service/MaterialService.java

@@ -18,4 +18,6 @@ public interface MaterialService extends IBaseService<MaterialEntity, Long> {
     Result search(PageDto param);
 
     Result download(Long id);
+
+    Result remove(Long id);
 }

+ 17 - 0
gis_service/src/main/java/com/gis/service/impl/MaterialServiceImpl.java

@@ -102,4 +102,21 @@ public class MaterialServiceImpl extends IBaseServiceImpl<MaterialEntity, Long>
         log.info("url: {}", url);
         return Result.success(url);
     }
+
+    @Override
+    public Result remove(Long id) {
+        MaterialEntity entity = this.findById(id);
+        if (entity == null) {
+            return Result.success();
+        }
+        // db数据软删除, 物理数据真删除
+        String code = entity.getCode();
+        String srcPath = configConstant.serverBasePath + "material/" + code;
+        FileUtil.del(srcPath);
+        log.info("文件删除完成: {}", srcPath );
+        entity.setIsDelete(1);
+        entity.setUpdateTime(new Date());
+        this.update(entity);
+        return  Result.success();
+    }
 }

+ 9 - 1
gis_web/src/main/java/com/gis/web/controller/MaterialController.java

@@ -33,10 +33,18 @@ public class MaterialController extends BaseController {
     @WebControllerLog(description = "史料管理-下载史料", addDb = true)
     @ApiOperation("下载史料")
     @GetMapping("download/{id}")
-    public Result<MaterialEntity> download(@PathVariable Long id) {
+    public Result download(@PathVariable Long id) {
         return materialService.download(id);
     }
 
+    @WebControllerLog(description = "史料管理-删除", addDb = true)
+    @ApiOperation(value = "删除", notes = "db数据软删除, 物理数据真删除")
+    @GetMapping("remove/{id}")
+    public Result remove(@PathVariable Long id) {
+        return materialService.remove(id);
+    }
+
+
 
 
 }