|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -74,24 +75,26 @@ public class ZbFileServiceImpl extends ServiceImpl<ZbFileMapper, ZbFile> impleme
|
|
|
public boolean deletePicture(ZbFile zbFile) {
|
|
|
try {
|
|
|
Integer id = zbFile.getId();
|
|
|
- if (id == null){
|
|
|
+ if (id == null) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isEmpty(zbFile.getPath())){
|
|
|
+ if (StringUtils.isEmpty(zbFile.getPath())) {
|
|
|
zbFile = baseMapper.selectById(id);
|
|
|
}
|
|
|
- File file = new File(RuoYiConfig.getProfile() + File.separator + zbFile.getPath());
|
|
|
- log.info("删除原始文件: " + file);
|
|
|
- FileUtils.forceDelete(file);
|
|
|
- String thumbnailPath = zbFile.getThumbnailPath();
|
|
|
- if (StringUtils.isNotEmpty(thumbnailPath)){
|
|
|
- File fileThumbnail = new File(RuoYiConfig.getProfile() + File.separator + thumbnailPath);
|
|
|
- log.info("删除缩略图文件: " + fileThumbnail);
|
|
|
- FileUtils.forceDelete(fileThumbnail);
|
|
|
+ if (ObjectUtil.isNotEmpty(zbFile)) {
|
|
|
+ File file = new File(RuoYiConfig.getProfile() + File.separator + zbFile.getPath());
|
|
|
+ log.info("删除原始文件: " + file);
|
|
|
+ FileUtils.forceDelete(file);
|
|
|
+ String thumbnailPath = zbFile.getThumbnailPath();
|
|
|
+ if (StringUtils.isNotEmpty(thumbnailPath)) {
|
|
|
+ File fileThumbnail = new File(RuoYiConfig.getProfile() + File.separator + thumbnailPath);
|
|
|
+ log.info("删除缩略图文件: " + fileThumbnail);
|
|
|
+ FileUtils.forceDelete(fileThumbnail);
|
|
|
+ }
|
|
|
+
|
|
|
+ baseMapper.deleteById(id);
|
|
|
}
|
|
|
-
|
|
|
- baseMapper.deleteById(id);
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
log.info("删除文件失败");
|
|
@@ -102,21 +105,23 @@ public class ZbFileServiceImpl extends ServiceImpl<ZbFileMapper, ZbFile> impleme
|
|
|
|
|
|
|
|
|
* 根据ids查询数据
|
|
|
+ *
|
|
|
* @param fileIdsArr
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public List<ZbFile> selectByIds(String[] fileIdsArr) {
|
|
|
- return baseMapper.selectByIds(fileIdsArr);
|
|
|
+ return baseMapper.selectByIds(fileIdsArr);
|
|
|
}
|
|
|
|
|
|
|
|
|
* 删除附件表信息
|
|
|
+ *
|
|
|
* @param fileIdsArr
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Integer deleteByIds(String[] fileIdsArr) {
|
|
|
- return baseMapper.deleteByIds(fileIdsArr);
|
|
|
+ return baseMapper.deleteByIds(fileIdsArr);
|
|
|
}
|
|
|
}
|