|
|
@@ -13,6 +13,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@@ -56,14 +61,32 @@ public class CourseWareController {
|
|
|
return OkResponse.of(courseWareService.getCourseWareById(id));
|
|
|
}
|
|
|
|
|
|
-// @GetMapping("/download")
|
|
|
-// public OkResponse<String> downloadCourseWare(HttpServletRequest req, HttpServletResponse res, @RequestParam Long id) throws IOException {
|
|
|
-// return OkResponse.of(courseWareService.downloadCourseWare(req, res, id));
|
|
|
-// }
|
|
|
-
|
|
|
@PostMapping("/changeCourseWareName")
|
|
|
public OkResponse<String> changeCourseWareName(@RequestParam Long id, @RequestParam String newName) {
|
|
|
return OkResponse.of(courseWareService.changeCourseWareName(id, newName));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/getUrlById")
|
|
|
+ public OkResponse<String> getCourseWareUrlById(@RequestParam Long id) {
|
|
|
+ return OkResponse.of(courseWareService.getCourseWareUrlById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequestMapping(name = "/showPdf")
|
|
|
+// public String showPdf(HttpServletRequest request, HttpServletResponse response, String pdfUrl) {
|
|
|
+// try {
|
|
|
+// pdfUrl = pdfUrl.trim();
|
|
|
+// URL url = new URL(pdfUrl);
|
|
|
+// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
+// conn.setConnectTimeout(5*1000);
|
|
|
+// InputStream inputStream = conn.getInputStream();
|
|
|
+// response.setHeader("Content-Disposition", "attachment;fileName=show.pdf");
|
|
|
+// response.setContentType("multipart/form-data");
|
|
|
+// OutputStream outputStream = response.getOutputStream();
|
|
|
+// IOUtils.write(IOUtils.toByteArray(inputStream), outputStream);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+
|
|
|
}
|