|
@@ -1,5 +1,6 @@
|
|
|
package com.gis.cms.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -40,8 +41,6 @@ public class FodderServiceImpl extends ServiceImpl<FodderMapper, FodderEntity> i
|
|
|
IBaseService iBaseService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
FileUtils fileUtils;
|
|
|
|
|
@@ -55,16 +54,14 @@ public class FodderServiceImpl extends ServiceImpl<FodderMapper, FodderEntity> i
|
|
|
WorkService workService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public Result search(PageDto param) {
|
|
|
BaseUtil.startPage(param);
|
|
|
- IPage<FodderEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
- LambdaQueryWrapper<FodderEntity> wrapper = new LambdaQueryWrapper<> ();
|
|
|
+ IPage<FodderEntity> page = new Page<>(param.getPageNum(), param.getPageSize());
|
|
|
+ LambdaQueryWrapper<FodderEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(FodderEntity::getCreatorId, iBaseService.getUserId());
|
|
|
String searchKey = param.getSearchKey();
|
|
|
- if (StringUtils.isNotBlank(searchKey)){
|
|
|
+ if (StringUtils.isNotBlank(searchKey)) {
|
|
|
wrapper.like(FodderEntity::getFileName, searchKey);
|
|
|
}
|
|
|
wrapper.orderByDesc(FodderEntity::getCreateTime);
|
|
@@ -75,13 +72,15 @@ public class FodderServiceImpl extends ServiceImpl<FodderMapper, FodderEntity> i
|
|
|
@Override
|
|
|
public Result remove(String id) {
|
|
|
|
|
|
- FodderEntity entity = this.getById(id);
|
|
|
- // 检查场景是否被引用
|
|
|
- boolean exist = workService.existBySceneCode(entity.getSceneCode());
|
|
|
- BaseRuntimeException.isHas(exist, null, "此场景被作品使用中,不能删除");
|
|
|
- // 真删除目录
|
|
|
- fileUtils.del(entity.getFilePath());
|
|
|
- this.removeById(id);
|
|
|
+ FodderEntity entity = this.getById(id);
|
|
|
+ // 检查场景是否被引用
|
|
|
+ boolean exist = workService.existBySceneCode(entity.getSceneCode());
|
|
|
+ BaseRuntimeException.isHas(exist, null, "此场景被作品使用中,不能删除");
|
|
|
+ // 真删除目录
|
|
|
+ String delPath = entity.getFilePath();
|
|
|
+ FileUtil.del(delPath);
|
|
|
+ log.info("真删除文件: {}", delPath);
|
|
|
+ this.removeById(id);
|
|
|
|
|
|
return Result.success();
|
|
|
}
|