|
|
@@ -73,7 +73,7 @@ public class CourseWareServiceImpl implements CourseWareService {
|
|
|
public List<CourseWareDTO> getCourseWaresByCourseId(Long courseId) {
|
|
|
System.out.println("get");
|
|
|
List<CourseWareDTO> result = courseWareRepository.findCourseWaresByCourseIdAndStateNot(courseId, ObjectState.DELETED).stream()
|
|
|
- .sorted(Comparator.comparing(CourseWare::getCreatedTime))
|
|
|
+ .sorted(Comparator.comparing(CourseWare::getUseMethod).thenComparing(CourseWare::getCreatedTime))
|
|
|
.map(courseWare -> new CourseWareDTO(courseWareMapper.toCourseWareVO(courseWare)))
|
|
|
.collect(Collectors.toList());
|
|
|
return result;
|
|
|
@@ -98,57 +98,43 @@ public class CourseWareServiceImpl implements CourseWareService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String downloadCourseWare(HttpServletRequest req, HttpServletResponse res, Long id) throws IOException {
|
|
|
- System.out.println("download");
|
|
|
- CourseWare courseWare = courseWareRepository.findCourseWareById(id);
|
|
|
- String fileName = courseWare.getName();
|
|
|
- String filePath = courseWare.getFileUrl();
|
|
|
-
|
|
|
- OutputStream os = null;
|
|
|
- InputStream is = null;
|
|
|
- try{
|
|
|
- res.reset();
|
|
|
- res.setCharacterEncoding("utf-8");
|
|
|
- res.setContentType("application/octet-stream");
|
|
|
- res.setHeader("Content-Disposition", "attachment;" + new String(fileName.getBytes("gb2312"), "ISO8859-1"));
|
|
|
- File f = new File(filePath);
|
|
|
- is = new FileInputStream(f);
|
|
|
- ServletOutputStream sout = res.getOutputStream();
|
|
|
- BufferedInputStream bis = null;
|
|
|
- BufferedOutputStream bos = null;
|
|
|
- bis = new BufferedInputStream(is);
|
|
|
- bos = new BufferedOutputStream(sout);
|
|
|
- byte[] buff = new byte[2048];
|
|
|
- int bytesRead;
|
|
|
- while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
|
|
|
- bos.write(buff, 0, bytesRead);
|
|
|
- }
|
|
|
- bos.flush();
|
|
|
- bos.close();
|
|
|
- bis.close();
|
|
|
- is.close();
|
|
|
- os.close();
|
|
|
- }catch (Exception e){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return fileName;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String getSlideUrl(Long slideId) {
|
|
|
- System.out.println("geturl");
|
|
|
- CourseWare courseWare = courseWareRepository.findCourseWareById(slideId);
|
|
|
- return courseWare.getFileUrl();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public CourseWareVO getSlideInfo(Long slideId) {
|
|
|
- System.out.println("getinfo");
|
|
|
- CourseWare courseWare = courseWareRepository.findCourseWareById(slideId);
|
|
|
- return courseWareMapper.toCourseWareVO(courseWare);
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public String downloadCourseWare(HttpServletRequest req, HttpServletResponse res, Long id) throws IOException {
|
|
|
+// System.out.println("download");
|
|
|
+// CourseWare courseWare = courseWareRepository.findCourseWareById(id);
|
|
|
+// String fileName = courseWare.getName();
|
|
|
+// String filePath = courseWare.getFileUrl();
|
|
|
+//
|
|
|
+// OutputStream os = null;
|
|
|
+// InputStream is = null;
|
|
|
+// try{
|
|
|
+// res.reset();
|
|
|
+// res.setCharacterEncoding("utf-8");
|
|
|
+// res.setContentType("application/octet-stream");
|
|
|
+// res.setHeader("Content-Disposition", "attachment;" + new String(fileName.getBytes("gb2312"), "ISO8859-1"));
|
|
|
+// File f = new File(filePath);
|
|
|
+// is = new FileInputStream(f);
|
|
|
+// ServletOutputStream sout = res.getOutputStream();
|
|
|
+// BufferedInputStream bis = null;
|
|
|
+// BufferedOutputStream bos = null;
|
|
|
+// bis = new BufferedInputStream(is);
|
|
|
+// bos = new BufferedOutputStream(sout);
|
|
|
+// byte[] buff = new byte[2048];
|
|
|
+// int bytesRead;
|
|
|
+// while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
|
|
|
+// bos.write(buff, 0, bytesRead);
|
|
|
+// }
|
|
|
+// bos.flush();
|
|
|
+// bos.close();
|
|
|
+// bis.close();
|
|
|
+// is.close();
|
|
|
+// os.close();
|
|
|
+// }catch (Exception e){
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// return fileName;
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public String changeCourseWareName(Long id, String newName) {
|