|
|
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.file.FileUtils;
|
|
|
import com.zhongzheng.modules.course.bo.CourseHandoutsAddBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseHandoutsEditBo;
|
|
|
import com.zhongzheng.modules.course.domain.CourseFile;
|
|
|
@@ -17,10 +19,15 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.nio.charset.Charset;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
@@ -70,6 +77,15 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
|
|
|
}
|
|
|
|
|
|
iCourseHandoutsService.updateHandouts(fromPath,bo);
|
|
|
+
|
|
|
+ //删除本地资源
|
|
|
+ Path pathStr = Paths.get(fromPath);
|
|
|
+ try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
+ }catch (IOException e) {
|
|
|
+ log.error("讲义删除本地资源失败:"+ DateUtils.getNowTime());
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -87,6 +103,14 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
|
|
|
}
|
|
|
}
|
|
|
iCourseHandoutsService.addHandouts(fromPath,bo);
|
|
|
+ //删除本地资源
|
|
|
+ Path pathStr = Paths.get(fromPath);
|
|
|
+ try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
+ }catch (IOException e) {
|
|
|
+ log.error("讲义删除本地资源失败:"+ DateUtils.getNowTime());
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|