|
@@ -16,6 +16,7 @@ import com.doc.common.enums.BusinessType;
|
|
|
import com.doc.common.enums.EventLevel;
|
|
|
import com.doc.common.utils.DateUtils;
|
|
|
import com.doc.common.utils.SecurityUtils;
|
|
|
+import com.doc.common.utils.StringUtils;
|
|
|
import com.doc.common.utils.file.FileUtils;
|
|
|
import com.doc.common.utils.poi.ExcelUtil;
|
|
|
import io.swagger.annotations.*;
|
|
@@ -103,7 +104,7 @@ public class DocInfoController extends BaseController {
|
|
|
* @param spaceId 空间ID
|
|
|
* @param dirId 目录ID
|
|
|
*/
|
|
|
- private void process(DocumentVO vo, Long spaceId, Long dirId) {
|
|
|
+ private DocInfo process(DocumentVO vo, Long spaceId, Long dirId) {
|
|
|
DocInfo docInfo = new DocInfo();
|
|
|
docInfo.setSpaceId(spaceId);
|
|
|
docInfo.setDirId(dirId);
|
|
@@ -113,6 +114,7 @@ public class DocInfoController extends BaseController {
|
|
|
docInfo.setFileType(vo.getSuffix());
|
|
|
docInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
docInfoService.insertDocInfo(docInfo);
|
|
|
+ return docInfo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -123,10 +125,11 @@ public class DocInfoController extends BaseController {
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "type", value = "文件类型 \"word\":word文档 \"excel\":excel文件 \"ppt\":ppt文件 \"txt\":文本文件", required = true),
|
|
|
@ApiImplicitParam(name = "spaceId", value = "空间ID", required = true),
|
|
|
- @ApiImplicitParam(name = "dirId", value = "目录ID", required = true)
|
|
|
+ @ApiImplicitParam(name = "dirId", value = "目录ID", required = true),
|
|
|
+ @ApiImplicitParam(name = "name", value = "文件名", required = true)
|
|
|
})
|
|
|
@Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
|
|
|
- public AjaxResult create(Long spaceId, Long dirId, String type) {
|
|
|
+ public AjaxResult create(Long spaceId, Long dirId, String type, String name) {
|
|
|
try {
|
|
|
String filePath = "";
|
|
|
String fileName = "";
|
|
@@ -149,11 +152,15 @@ public class DocInfoController extends BaseController {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ if (StringUtils.isEmpty(name)) {
|
|
|
+ name = fileName;
|
|
|
+ }
|
|
|
+
|
|
|
InputStream is = this.getClass().getResourceAsStream("/" + filePath);
|
|
|
- MultipartFile multipartFile = FileUtils.getMultipartFile(is, fileName);
|
|
|
+ MultipartFile multipartFile = FileUtils.getMultipartFile(is, name);
|
|
|
DocumentVO vo = mongoService.uploadFile(multipartFile);
|
|
|
- process(vo, spaceId, dirId);
|
|
|
- return success();
|
|
|
+ DocInfo docInfo = process(vo, spaceId, dirId);
|
|
|
+ return success(docInfo);
|
|
|
} catch (Exception e) {
|
|
|
log.error("新建文件出错啦:{}", e.getMessage());
|
|
|
return error("新建文件出错");
|