|
@@ -4,6 +4,7 @@ package com.zglc.fm.controller;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.zglc.fm.base.Result;
|
|
import com.zglc.fm.base.Result;
|
|
|
|
+import com.zglc.fm.entity.CatalogueEntity;
|
|
import com.zglc.fm.entity.DeleteEntity;
|
|
import com.zglc.fm.entity.DeleteEntity;
|
|
import com.zglc.fm.entity.BookEntity;
|
|
import com.zglc.fm.entity.BookEntity;
|
|
import com.zglc.fm.entity.FaultEntity;
|
|
import com.zglc.fm.entity.FaultEntity;
|
|
@@ -55,45 +56,57 @@ public class BookController {
|
|
String sourcePath1;
|
|
String sourcePath1;
|
|
|
|
|
|
sourcePath1 = "d:\\sourcefm";
|
|
sourcePath1 = "d:\\sourcefm";
|
|
- String filePath = FileTool.fileUp(file, sourcePath1, date.getTime() + file.getOriginalFilename());
|
|
|
|
|
|
+ String extName = ""; // 扩展名格式:
|
|
|
|
+
|
|
|
|
+// String filePath = FileTool.fileUp(file, sourcePath1, date.getTime() + file.getOriginalFilename());
|
|
|
|
+ extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
|
+ String filePath = FileTool.fileUp(file, sourcePath1, date.getTime() + extName);
|
|
|
|
|
|
- FileTypeUtil.Type fileType = FileTypeUtil.getFileType(file.getOriginalFilename());
|
|
|
|
|
|
+ Type fileType = FileTypeUtil.getFileType(file.getOriginalFilename());
|
|
if (fileType == FileTypeUtil.Type.DOC || fileType == FileTypeUtil.Type.DOCX || fileType == FileTypeUtil.Type.RTF ) {
|
|
if (fileType == FileTypeUtil.Type.DOC || fileType == FileTypeUtil.Type.DOCX || fileType == FileTypeUtil.Type.RTF ) {
|
|
DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
|
|
DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
|
|
}
|
|
}
|
|
if (fileType == FileTypeUtil.Type.PPT || fileType == FileTypeUtil.Type.PPTX) {
|
|
if (fileType == FileTypeUtil.Type.PPT || fileType == FileTypeUtil.Type.PPTX) {
|
|
Ppt2ToPdf.convertPpt2Pdf(filePath, sourcePath1);
|
|
Ppt2ToPdf.convertPpt2Pdf(filePath, sourcePath1);
|
|
}
|
|
}
|
|
- if (fileType == FileTypeUtil.Type.DOC) {
|
|
|
|
- deleteDir(new File(filePath));
|
|
|
|
- filePath = filePath.replaceAll( "doc","pdf");
|
|
|
|
- }
|
|
|
|
- if (fileType == FileTypeUtil.Type.DOCX) {
|
|
|
|
- deleteDir(new File(filePath));
|
|
|
|
- filePath = filePath.replaceAll( "docx","pdf");
|
|
|
|
- }
|
|
|
|
- if (fileType == FileTypeUtil.Type.RTF) {
|
|
|
|
- deleteDir(new File(filePath));
|
|
|
|
- filePath = filePath.replaceAll( "rtf","pdf");
|
|
|
|
- }
|
|
|
|
- if (fileType == FileTypeUtil.Type.PPT) {
|
|
|
|
- deleteDir(new File(filePath));
|
|
|
|
- filePath = filePath.replaceAll( "ppt","pdf");
|
|
|
|
- }
|
|
|
|
- if (fileType == FileTypeUtil.Type.PPTX) {
|
|
|
|
- deleteDir(new File(filePath));
|
|
|
|
- filePath = filePath.replaceAll( "pptx","pdf");
|
|
|
|
- }
|
|
|
|
|
|
+// if (fileType == FileTypeUtil.Type.DOC) {
|
|
|
|
+//// deleteDir(new File(filePath));
|
|
|
|
+// filePath = filePath.replaceAll( "doc","pdf");
|
|
|
|
+// }
|
|
|
|
+// if (fileType == FileTypeUtil.Type.DOCX) {
|
|
|
|
+//// deleteDir(new File(filePath));
|
|
|
|
+// filePath = filePath.replaceAll( "docx","pdf");
|
|
|
|
+// }
|
|
|
|
+// if (fileType == FileTypeUtil.Type.RTF) {
|
|
|
|
+//// deleteDir(new File(filePath));
|
|
|
|
+// filePath = filePath.replaceAll( "rtf","pdf");
|
|
|
|
+// }
|
|
|
|
+// if (fileType == FileTypeUtil.Type.PPT) {
|
|
|
|
+//// deleteDir(new File(filePath));
|
|
|
|
+// filePath = filePath.replaceAll( "ppt","pdf");
|
|
|
|
+// }
|
|
|
|
+// if (fileType == FileTypeUtil.Type.PPTX) {
|
|
|
|
+//// deleteDir(new File(filePath));
|
|
|
|
+// filePath = filePath.replaceAll( "pptx","pdf");
|
|
|
|
+// }
|
|
filePath = filePath.replaceAll( "d:","");
|
|
filePath = filePath.replaceAll( "d:","");
|
|
return Result.success(filePath);
|
|
return Result.success(filePath);
|
|
}
|
|
}
|
|
- private void deleteDir(File file) {
|
|
|
|
- if (file == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- file.delete();
|
|
|
|
- }
|
|
|
|
|
|
+// private void deleteDir(File file) {
|
|
|
|
+// if (file == null) {
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
+// file.delete();
|
|
|
|
+// }
|
|
|
|
|
|
|
|
+ @ApiOperation("浏览资料")
|
|
|
|
+ @ApiResponses({
|
|
|
|
+ @ApiResponse(code = 0, message = "成功")
|
|
|
|
+ })
|
|
|
|
+ @GetMapping("browse")
|
|
|
|
+ public Result<String> browse(@RequestParam String filepath){
|
|
|
|
+ return bookService.browse(filepath);
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation("导入教材缩略图")
|
|
@ApiOperation("导入教材缩略图")
|
|
@ApiResponses({
|
|
@ApiResponses({
|
|
@@ -175,6 +188,21 @@ public class BookController {
|
|
@PostMapping("add")
|
|
@PostMapping("add")
|
|
public Result<String> add(@RequestBody BookEntity data){return bookService.add(data);}
|
|
public Result<String> add(@RequestBody BookEntity data){return bookService.add(data);}
|
|
|
|
|
|
|
|
+ @ApiOperation("增添文档目录")
|
|
|
|
+ @ApiResponses({
|
|
|
|
+ @ApiResponse(code = 0, message = "成功")
|
|
|
|
+ })
|
|
|
|
+ @PostMapping("addDoccatalogue")
|
|
|
|
+ public Result<String> addDoccatalogue(@RequestParam Integer id) throws Exception {return bookService.addDoccatalogue(id);}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation("列出文档目录")
|
|
|
|
+ @ApiResponses({ @ApiResponse(code = 0, message = "成功")})
|
|
|
|
+ @PostMapping("listAllDoccatalogue")
|
|
|
|
+ public Result<List<CatalogueEntity>> listAllDoccatalogue(Integer bookId) {
|
|
|
|
+ return Result.success( bookService.listAllDoccatalogue(bookId));
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation("删除")
|
|
@ApiOperation("删除")
|
|
@ApiResponses({
|
|
@ApiResponses({
|
|
@ApiResponse(code = 0, message = "成功")
|
|
@ApiResponse(code = 0, message = "成功")
|