|
@@ -2,6 +2,7 @@ package com.siwei.apply.controller;
|
|
|
|
|
|
|
|
import com.siwei.apply.domain.NodeAttachment;
|
|
import com.siwei.apply.domain.NodeAttachment;
|
|
|
import com.siwei.apply.service.NodeAttachmentService;
|
|
import com.siwei.apply.service.NodeAttachmentService;
|
|
|
|
|
+import com.siwei.apply.utils.ServiceFileUtil;
|
|
|
import com.siwei.common.core.domain.R;
|
|
import com.siwei.common.core.domain.R;
|
|
|
import com.siwei.common.core.utils.StringUtils;
|
|
import com.siwei.common.core.utils.StringUtils;
|
|
|
import com.siwei.common.core.web.controller.BaseController;
|
|
import com.siwei.common.core.web.controller.BaseController;
|
|
@@ -211,10 +212,11 @@ public class NodeAttachmentController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@PostMapping("/processOneFile")
|
|
@PostMapping("/processOneFile")
|
|
|
public R<Map<String, String>> processOneFile(@RequestBody Map<String, String> requestBody) {
|
|
public R<Map<String, String>> processOneFile(@RequestBody Map<String, String> requestBody) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ String rootPath = requestBody.get("rootPath");
|
|
|
|
|
+ String nodeAttachmentId = requestBody.get("id");
|
|
|
String filePath = requestBody.get("filePath");
|
|
String filePath = requestBody.get("filePath");
|
|
|
String fileUploadPath = requestBody.get("fileUploadPath");
|
|
String fileUploadPath = requestBody.get("fileUploadPath");
|
|
|
if (filePath == null || filePath.trim().isEmpty()) {
|
|
if (filePath == null || filePath.trim().isEmpty()) {
|
|
@@ -223,24 +225,18 @@ public class NodeAttachmentController extends BaseController {
|
|
|
if (fileUploadPath == null || fileUploadPath.trim().isEmpty()) {
|
|
if (fileUploadPath == null || fileUploadPath.trim().isEmpty()) {
|
|
|
return R.fail(502,"fileUploadPath");
|
|
return R.fail(502,"fileUploadPath");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //这里把文件迁移到当前目录中,重新更新目录结构
|
|
|
|
|
- //String id = nodeAttachmentService.processFileAndSave(filePath);
|
|
|
|
|
- String id = "11111111222";
|
|
|
|
|
- if (id != null) {
|
|
|
|
|
- Map<String, String> responseData = new HashMap<>();
|
|
|
|
|
- responseData.put("nodeAttachmentId", id);
|
|
|
|
|
- return R.ok(responseData);
|
|
|
|
|
- } else {
|
|
|
|
|
- return R.fail("处理一个文件失败");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //文件移动
|
|
|
|
|
+ String movePath = ServiceFileUtil.moveFileToDirectory(filePath,fileUploadPath);
|
|
|
|
|
+ nodeAttachmentService.restFileAttachment(rootPath,nodeAttachmentId);
|
|
|
|
|
+ Map<String, String> responseData = new HashMap<>();
|
|
|
|
|
+ responseData.put("nodeAttachmentId", nodeAttachmentId);
|
|
|
|
|
+ return R.ok(responseData);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("处理文件异常", e);
|
|
logger.error("处理文件异常", e);
|
|
|
return R.fail("处理一个文件异常:" + e.getMessage());
|
|
return R.fail("处理一个文件异常:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 当用户进入此页面进行数据初始化
|
|
* 当用户进入此页面进行数据初始化
|
|
|
*
|
|
*
|
|
@@ -248,22 +244,19 @@ public class NodeAttachmentController extends BaseController {
|
|
|
* @return 数据库存储后的id
|
|
* @return 数据库存储后的id
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/initProcess")
|
|
@PostMapping("/initProcess")
|
|
|
- public R<Map<String, String>> initProcessFile(@RequestBody Map<String, String> requestBody) {
|
|
|
|
|
|
|
+ public R<NodeAttachment> initProcessFile(@RequestBody Map<String, String> requestBody) {
|
|
|
try {
|
|
try {
|
|
|
String nodeId = requestBody.get("nodeId");
|
|
String nodeId = requestBody.get("nodeId");
|
|
|
String projectId = requestBody.get("projectId");
|
|
String projectId = requestBody.get("projectId");
|
|
|
if (StringUtils.isBlank(nodeId)) {
|
|
if (StringUtils.isBlank(nodeId)) {
|
|
|
return R.fail("nodeId不能为空");
|
|
return R.fail("nodeId不能为空");
|
|
|
}
|
|
}
|
|
|
- String id = null;
|
|
|
|
|
NodeAttachment nodeAttachment = nodeAttachmentService.getByNodeId(nodeId);
|
|
NodeAttachment nodeAttachment = nodeAttachmentService.getByNodeId(nodeId);
|
|
|
//增加一条空目录结构
|
|
//增加一条空目录结构
|
|
|
if (Objects.isNull(nodeAttachment)) {
|
|
if (Objects.isNull(nodeAttachment)) {
|
|
|
- id = nodeAttachmentService.addDefaultAttachment(projectId,nodeId);
|
|
|
|
|
|
|
+ nodeAttachment = nodeAttachmentService.addDefaultAttachment(projectId,nodeId);
|
|
|
}
|
|
}
|
|
|
- Map<String, String> responseData = new HashMap<>();
|
|
|
|
|
- responseData.put("nodeAttachmentId", id);
|
|
|
|
|
- return R.ok(responseData);
|
|
|
|
|
|
|
+ return R.ok(nodeAttachment);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("初始化附件信息异常", e);
|
|
logger.error("初始化附件信息异常", e);
|
|
|
return R.fail(502,"初始化附件信息异常:" + e.getMessage());
|
|
return R.fail(502,"初始化附件信息异常:" + e.getMessage());
|
|
@@ -272,6 +265,8 @@ public class NodeAttachmentController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|