实现了数据库和工程操作相关的操作记录功能。
This commit is contained in:
parent
e47e4bd3e8
commit
3057b9cf7c
|
|
@ -27,33 +27,33 @@ public class EdFileInfoController {
|
||||||
@Resource
|
@Resource
|
||||||
private EdFileInfoService edFileInfoService;
|
private EdFileInfoService edFileInfoService;
|
||||||
|
|
||||||
@UserOperation(value = "查看了工程树", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping("tree")
|
@RequestMapping("tree")
|
||||||
public ElectromagneticResult<?> tree() {
|
public ElectromagneticResult<?> tree() {
|
||||||
return edFileInfoService.tree(DataOwnEnum.SYS_PRJ.code);
|
return edFileInfoService.tree(DataOwnEnum.SYS_PRJ.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "创建了文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping("createFolder")
|
@RequestMapping("createFolder")
|
||||||
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
|
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
|
||||||
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.COMMON.code);
|
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "作废了文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "作废文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.DELETE)
|
@RequiredPermission(value = FilePermission.DELETE)
|
||||||
@RequestMapping("delete")
|
@RequestMapping("delete")
|
||||||
public ElectromagneticResult<?> delete(@RequestParam String id) {
|
public ElectromagneticResult<?> delete(@RequestParam String id) {
|
||||||
return edFileInfoService.delete(id, DataOwnEnum.COMMON.code);
|
return edFileInfoService.delete(id, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "查询了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查询文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.VIEW)
|
@RequiredPermission(value = FilePermission.VIEW)
|
||||||
@RequestMapping("info")
|
@RequestMapping("info")
|
||||||
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||||
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.COMMON.code);
|
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "上传了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "上传文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.UPLOAD)
|
@RequiredPermission(value = FilePermission.UPLOAD)
|
||||||
@RequestMapping("upload")
|
@RequestMapping("upload")
|
||||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||||
|
|
@ -62,21 +62,21 @@ public class EdFileInfoController {
|
||||||
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.COMMON.code);
|
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "下载了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "下载文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||||
@RequestMapping("download")
|
@RequestMapping("download")
|
||||||
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
|
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
|
||||||
return edFileInfoService.download(id, response, DataOwnEnum.COMMON.code);
|
return edFileInfoService.download(id, response, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "更新了文件信息", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "更新文件信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.EDIT)
|
@RequiredPermission(value = FilePermission.EDIT)
|
||||||
@RequestMapping("updateFileInfo")
|
@RequestMapping("updateFileInfo")
|
||||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
||||||
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.COMMON.code);
|
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "移动了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "移动文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.MOVE)
|
@RequiredPermission(value = FilePermission.MOVE)
|
||||||
@RequestMapping("moveFile")
|
@RequestMapping("moveFile")
|
||||||
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
|
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
|
||||||
|
|
@ -85,7 +85,7 @@ public class EdFileInfoController {
|
||||||
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.COMMON.code);
|
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "复制了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "复制文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.MOVE)
|
@RequiredPermission(value = FilePermission.MOVE)
|
||||||
@RequestMapping("copyFile")
|
@RequestMapping("copyFile")
|
||||||
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
|
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
|
||||||
|
|
@ -94,27 +94,27 @@ public class EdFileInfoController {
|
||||||
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.COMMON.code);
|
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "查看了文件历史版本信息", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查看文件历史版本信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.VIEW)
|
@RequiredPermission(value = FilePermission.VIEW)
|
||||||
@RequestMapping("versionView")
|
@RequestMapping("versionView")
|
||||||
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
|
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
|
||||||
return edFileInfoService.versionView(fileId);
|
return edFileInfoService.versionView(fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "回退了版本", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "回退版本", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.EDIT)
|
@RequiredPermission(value = FilePermission.EDIT)
|
||||||
@RequestMapping("versionBack")
|
@RequestMapping("versionBack")
|
||||||
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
|
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
|
||||||
return edFileInfoService.versionBack(fileId, targetVersion);
|
return edFileInfoService.versionBack(fileId, targetVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "导出了数据库", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "导出数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping("batchExport")
|
@RequestMapping("batchExport")
|
||||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
|
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
|
||||||
return edFileInfoService.batchExport(fileIds, response, DataOwnEnum.COMMON.code);
|
return edFileInfoService.batchExport(fileIds, response, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "批量上传了数据库", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||||
@RequestParam String fileName,
|
@RequestParam String fileName,
|
||||||
|
|
@ -122,39 +122,39 @@ public class EdFileInfoController {
|
||||||
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks, DataOwnEnum.COMMON.code);
|
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "批量上传了数据库", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||||
return edFileInfoService.batchImport(fileChunkDTO);
|
return edFileInfoService.batchImport(fileChunkDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "批量上传了数据库")
|
@UserOperation(value = "批量上传数据库")
|
||||||
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||||
return edFileInfoService.checkChunkExist(fileChunkDTO);
|
return edFileInfoService.checkChunkExist(fileChunkDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "查询了发布管理", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查询发布管理", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
|
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
|
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||||
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.COMMON.code);
|
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "查询了文件详细信息", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查询文件详细信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.VIEW)
|
@RequiredPermission(value = FilePermission.VIEW)
|
||||||
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
|
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> detail(@RequestParam String id) {
|
public ElectromagneticResult<?> detail(@RequestParam String id) {
|
||||||
return edFileInfoService.detail(id);
|
return edFileInfoService.detail(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "查询了子文件集", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查询子文件集", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.VIEW)
|
@RequiredPermission(value = FilePermission.VIEW)
|
||||||
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
|
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
|
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
|
||||||
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.COMMON.code);
|
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.COMMON.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "预览了文件", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "预览文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||||
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
||||||
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||||
import cn.hutool.core.lang.tree.TreeUtil;
|
import cn.hutool.core.lang.tree.TreeUtil;
|
||||||
|
import cn.hutool.core.text.StrFormatter;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
|
@ -167,9 +168,9 @@ public class CommonService {
|
||||||
public ElectromagneticResult<?> addFolder(String parentId, String folderName, boolean maxLengthCheck, String folderId, String fileNote, int dataOwnCode) {
|
public ElectromagneticResult<?> addFolder(String parentId, String folderName, boolean maxLengthCheck, String folderId, String fileNote, int dataOwnCode) {
|
||||||
|
|
||||||
// 验证名称是否合法
|
// 验证名称是否合法
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
|
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), StrFormatter.format("{} {}", folderName, NAME_VALID_MSG));
|
||||||
// 检查名称是否存在
|
// 检查名称是否存在
|
||||||
Assert.isTrue(notExistSameFolder(parentId, folderName, dataOwnCode), "该名称已存在");
|
Assert.isTrue(notExistSameFolder(parentId, folderName, dataOwnCode), StrFormatter.format("该名称 {} 已存在, 创建失败。", folderName));
|
||||||
|
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||||
|
|
@ -179,7 +180,7 @@ public class CommonService {
|
||||||
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
|
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
|
||||||
if (maxLengthCheck) {
|
if (maxLengthCheck) {
|
||||||
if (paths.size() >= prjFolderMaxLength) {
|
if (paths.size() >= prjFolderMaxLength) {
|
||||||
String info = "当前子集已达到最大层级,禁止创建子集。";
|
String info = StrFormatter.format( "当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
|
||||||
log.error(info);
|
log.error(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
}
|
}
|
||||||
|
|
@ -221,9 +222,9 @@ public class CommonService {
|
||||||
// 保存到文件系统
|
// 保存到文件系统
|
||||||
String targetFilePath = getEleDataPath(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
|
String targetFilePath = getEleDataPath(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
|
||||||
fileSystemService.createDirectory(targetFilePath);
|
fileSystemService.createDirectory(targetFilePath);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(folderId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = "添加失败";
|
String info = StrFormatter.format("{} 添加失败,原因 {}", folderName, e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
@ -300,9 +301,9 @@ public class CommonService {
|
||||||
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
||||||
String srcPrjName = srcFileInfo.getFileName();
|
String srcPrjName = srcFileInfo.getFileName();
|
||||||
String srcFilePath = getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
String srcFilePath = getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||||
|
EdFileInfo fileInfo = edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getId, id));
|
||||||
try {
|
try {
|
||||||
// 这里要分两种情况,1是删除层级目录,2是删除用户创建的文件夹
|
// 这里要分两种情况,1是删除层级目录,2是删除用户创建的文件夹
|
||||||
EdFileInfo fileInfo = edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getId, id));
|
|
||||||
String parentId = fileInfo.getParentId();
|
String parentId = fileInfo.getParentId();
|
||||||
if (fileInfo.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code)) { // 删除的是层级目录
|
if (fileInfo.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code)) { // 删除的是层级目录
|
||||||
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
|
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
|
||||||
|
|
@ -311,7 +312,7 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT));
|
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
String info = "禁止删除非空文件夹";
|
String info = StrFormatter.format("删除文件 {} 失败,目录非空。", fileInfo.getFileName());
|
||||||
log.info(info);
|
log.info(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -345,7 +346,7 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getParentId, id)
|
.eq(EdFileInfo::getParentId, id)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
String info = "禁止删除非空文件夹";
|
String info = StrFormatter.format("删除文件 {} 失败,目录非空。", fileInfo.getFileName());
|
||||||
log.info(info);
|
log.info(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -359,9 +360,10 @@ public class CommonService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fileSystemService.renameFile(srcFilePath, srcPrjName + "." + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
// fileSystemService.renameFile(srcFilePath, srcPrjName + "." + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "删除目录 {} 成功", fileInfo.getFileName());
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = "删除子集异常";
|
String info = StrFormatter.format("删除文件 {} 失败,目录非空。", fileInfo.getFileName());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ import com.electromagnetic.industry.software.manage.pojo.resp.*;
|
||||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.core.io.InputStreamResource;
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
|
@ -145,6 +144,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
long total = edFileInfoPage.getTotal();
|
long total = edFileInfoPage.getTotal();
|
||||||
List<FileInfoVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileInfoVO.class);
|
List<FileInfoVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileInfoVO.class);
|
||||||
resetFileSize(records);
|
resetFileSize(records);
|
||||||
|
UserThreadLocal.setSuccessInfo("", "查询搜索文件成功");
|
||||||
return ElectromagneticResultUtil.success(new FileInfoQueryPageVO(total, records));
|
return ElectromagneticResultUtil.success(new FileInfoQueryPageVO(total, records));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +172,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
public ElectromagneticResult<?> createFolder(CreateFolderDTO createFolderDTO, int dataOwnCode) {
|
public ElectromagneticResult<?> createFolder(CreateFolderDTO createFolderDTO, int dataOwnCode) {
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(createFolderDTO.getNewFolderName()), NAME_VALID_MSG);
|
Assert.isTrue(EleCommonUtil.isFileNameValid(createFolderDTO.getNewFolderName()), NAME_VALID_MSG);
|
||||||
String folderId = IdWorker.getSnowFlakeIdString();
|
String folderId = IdWorker.getSnowFlakeIdString();
|
||||||
return commonService.addFolder(createFolderDTO.getParentId(), createFolderDTO.getNewFolderName(), false, folderId, createFolderDTO.getFileNote(), dataOwnCode);
|
ElectromagneticResult<?> res = commonService.addFolder(createFolderDTO.getParentId(), createFolderDTO.getNewFolderName(), false, folderId, createFolderDTO.getFileNote(), dataOwnCode);
|
||||||
|
UserThreadLocal.setSuccessInfo(res.getData() + "", "创建文件夹成功");
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -193,6 +195,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
res.add(fileProjectVO);
|
res.add(fileProjectVO);
|
||||||
});
|
});
|
||||||
res.sort(Comparator.comparing(FileProjectVO::getSort));
|
res.sort(Comparator.comparing(FileProjectVO::getSort));
|
||||||
|
UserThreadLocal.setSuccessInfo("", "查询项目层级结构成功");
|
||||||
return ElectromagneticResultUtil.success(res);
|
return ElectromagneticResultUtil.success(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +209,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
public ElectromagneticResult<?> delete(String id, int dataOwnCode) {
|
public ElectromagneticResult<?> delete(String id, int dataOwnCode) {
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||||
if (fileInfo.getDataType() == EleDataTypeEnum.FOLDER.code) {
|
if (fileInfo.getDataType() == EleDataTypeEnum.FOLDER.code) {
|
||||||
return commonService.deleteFolder(id, dataOwnCode);
|
ElectromagneticResult<?> res = commonService.deleteFolder(id, dataOwnCode);
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "作废目录 {} 成功", fileInfo.getFileName());
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String currentUserId = UserThreadLocal.getUserId();
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
|
@ -216,6 +221,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.set(EdFileInfo::getEffectFlag, false)
|
.set(EdFileInfo::getEffectFlag, false)
|
||||||
.set(EdFileInfo::getAllDeleted, true)
|
.set(EdFileInfo::getAllDeleted, true)
|
||||||
.eq(EdFileInfo::getFileId, fileInfo.getFileId()));
|
.eq(EdFileInfo::getFileId, fileInfo.getFileId()));
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "作废目录 {} 成功", fileInfo.getFileName());
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,19 +233,20 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<InputStreamResource> download(String id, HttpServletResponse response, int dataOwnCode) {
|
public ResponseEntity<InputStreamResource> download(String id, HttpServletResponse response, int dataOwnCode) {
|
||||||
|
String fileName = "";
|
||||||
try {
|
try {
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||||
String fileSysPath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
String fileSysPath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
||||||
Assert.isTrue(FileUtil.exist(fileSysPath), "下载文件不存在。");
|
Assert.isTrue(FileUtil.exist(fileSysPath), "下载文件不存在。");
|
||||||
FileSystemResource fileSystemResource = new FileSystemResource(fileSysPath);
|
FileSystemResource fileSystemResource = new FileSystemResource(fileSysPath);
|
||||||
String fileName = fileSystemResource.getFilename();
|
fileName = fileSystemResource.getFilename();
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
headers.add("Pragma", "no-cache");
|
headers.add("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
fileName = Base64.encode(fileName.substring(0, fileName.lastIndexOf(".")));
|
String newFileName = Base64.encode(fileName.substring(0, fileName.lastIndexOf(".")));
|
||||||
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + newFileName);
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "下载文件 {} 成功", fileName);
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -248,7 +255,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
|
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
|
||||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = "下载文件异常";
|
String info = StrFormatter.format("下载文件异常 {}", fileName);
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +269,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> updateFileInfo(UpdateFileInfoDTO updateFileInfoDTO, int dataOwnCode) {
|
public ElectromagneticResult<?> updateFileInfo(UpdateFileInfoDTO updateFileInfoDTO, int dataOwnCode) {
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(updateFileInfoDTO.getFileName()), NAME_VALID_MSG);
|
String newFileName = updateFileInfoDTO.getFileName();
|
||||||
|
Assert.isTrue(EleCommonUtil.isFileNameValid(newFileName), StrFormatter.format("{} {}", newFileName, NAME_VALID_MSG));
|
||||||
try {
|
try {
|
||||||
// 首先检查新名称是否存在
|
// 首先检查新名称是否存在
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectById(updateFileInfoDTO.getId());
|
EdFileInfo fileInfo = this.baseMapper.selectById(updateFileInfoDTO.getId());
|
||||||
|
|
@ -289,7 +297,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
Map<String, EdFileInfo> map = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
Map<String, EdFileInfo> map = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
||||||
if (map.size() == 1) {
|
if (map.size() == 1) {
|
||||||
if (!map.values().iterator().next().getId().equals(updateFileInfoDTO.getId())) {
|
if (!map.values().iterator().next().getId().equals(updateFileInfoDTO.getId())) {
|
||||||
throw new BizException("文件名已经存在");
|
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("文件名 {} 已经存在", newFileName));
|
||||||
}
|
}
|
||||||
} else if (map.size() > 1) {
|
} else if (map.size() > 1) {
|
||||||
log.warn("数据库中存在了两份同名同后缀的文件");
|
log.warn("数据库中存在了两份同名同后缀的文件");
|
||||||
|
|
@ -307,11 +315,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote()));
|
.set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote()));
|
||||||
String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
|
String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
|
||||||
fileSystemService.renameFile(srcFilePath, newName);
|
fileSystemService.renameFile(srcFilePath, newName);
|
||||||
|
UserThreadLocal.setSuccessInfo(updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}", newFileName);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = "更新文件信息失败。";
|
String info = StrFormatter.format("更新文件信息失败,新文件名 {}, 原因 {}", newFileName, e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(e.getMessage());
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -335,10 +344,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.eq(EdFileInfo::getFileId, fileId)
|
.eq(EdFileInfo::getFileId, fileId)
|
||||||
.eq(EdFileInfo::getFileVersion, targetVersion));
|
.eq(EdFileInfo::getFileVersion, targetVersion));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = "版本回退失败。";
|
String info = "版本回退失败,新版本为" + targetVersion;
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
UserThreadLocal.setSuccessInfo(fileId, "回退版本成功,新版本为 {}", targetVersion);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,6 +441,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
ZipUtil.unzip(zipDirPath, tmpDir);
|
ZipUtil.unzip(zipDirPath, tmpDir);
|
||||||
update2Database(tmpDir, dataOwnCode);
|
update2Database(tmpDir, dataOwnCode);
|
||||||
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
||||||
|
UserThreadLocal.setSuccessInfo("", "导入数据库成功");
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -699,6 +710,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
headers.add("Pragma", "no-cache");
|
headers.add("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||||
|
UserThreadLocal.setSuccessInfo("", "导出数据库成功");
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -736,7 +748,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String mainName = FileUtil.mainName(fileName);
|
String mainName = FileUtil.mainName(fileName);
|
||||||
String suffix = FileUtil.getSuffix(fileName);
|
String suffix = FileUtil.getSuffix(fileName);
|
||||||
EdFileInfo newEdFileInfo = new EdFileInfo();
|
EdFileInfo newEdFileInfo = new EdFileInfo();
|
||||||
EdFileInfo finalEdFileInfo = null;
|
EdFileInfo finalEdFileInfo;
|
||||||
newEdFileInfo.newInit();
|
newEdFileInfo.newInit();
|
||||||
// 首先检查是否是同名文件
|
// 首先检查是否是同名文件
|
||||||
try {
|
try {
|
||||||
|
|
@ -791,7 +803,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
UserThreadLocal.setSuccessMsg(StrFormatter.format("文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}", fileName, destPath, strategyStr, finalEdFileInfo.getFileName()+ "." + finalEdFileInfo.getFileType()));
|
UserThreadLocal.setSuccessInfo(finalEdFileInfo.getId(), "文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}", fileName, destPath, strategyStr, finalEdFileInfo.getFileName()+ "." + finalEdFileInfo.getFileType());
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -807,6 +819,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.select(EdFileInfo::getParentId, EdFileInfo::getId, EdFileInfo::getFileId, EdFileInfo::getFileVersion, EdFileInfo::getPreVersion, EdFileInfo::getFileCode, EdFileInfo::getEffectFlag, EdFileInfo::getFileName)
|
.select(EdFileInfo::getParentId, EdFileInfo::getId, EdFileInfo::getFileId, EdFileInfo::getFileVersion, EdFileInfo::getPreVersion, EdFileInfo::getFileCode, EdFileInfo::getEffectFlag, EdFileInfo::getFileName)
|
||||||
.eq(EdFileInfo::getFileId, fileId));
|
.eq(EdFileInfo::getFileId, fileId));
|
||||||
List<FileVersionViewVO> fileVersionViewVOS = BeanUtil.copyToList(edFileInfos, FileVersionViewVO.class);
|
List<FileVersionViewVO> fileVersionViewVOS = BeanUtil.copyToList(edFileInfos, FileVersionViewVO.class);
|
||||||
|
UserThreadLocal.setSuccessInfo(fileId, "查询版本信息成功");
|
||||||
return ElectromagneticResultUtil.success(fileVersionViewVOS);
|
return ElectromagneticResultUtil.success(fileVersionViewVOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -849,18 +862,20 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String destFilePath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
String destFilePath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||||
fileSystemService.moveFile(srcFilePath, destFilePath);
|
fileSystemService.moveFile(srcFilePath, destFilePath);
|
||||||
} else {
|
} else {
|
||||||
return handMoveConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
|
srcFileInfo = handMoveConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
|
||||||
}
|
}
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "文件 {} 移动到 {},成功,处理文件同名同后缀的方式为 {},最终文件名为 {}", srcFileInfo.getFileName() + "." + srcFileInfo.getFileName(),
|
||||||
|
commonService.getDbPath(destFolderInfo.getFilePath()), FileRepeatEnum.getDesc(strategy), srcFileInfo.getFileName());
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElectromagneticResult<?> handMoveConflict(String targetFolderId, Integer strategy, EdFileInfo srcFileInfo, EdFileInfo destFolderInfo, int dataOwnCode) {
|
private EdFileInfo handMoveConflict(String targetFolderId, Integer strategy, EdFileInfo srcFileInfo, EdFileInfo destFolderInfo, int dataOwnCode) {
|
||||||
|
|
||||||
// 禁止同目录下移动和复制
|
// 禁止同目录下移动和复制
|
||||||
if (srcFileInfo.getParentId().equals(destFolderInfo.getId())) {
|
if (srcFileInfo.getParentId().equals(destFolderInfo.getId())) {
|
||||||
String info = "禁止相同文件夹下移动文件";
|
String info = "禁止相同文件夹下移动文件";
|
||||||
log.info(info);
|
log.info(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strategy == 2) {
|
if (strategy == 2) {
|
||||||
|
|
@ -891,6 +906,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||||
.eq(EdFileInfo::getId, fileInfoTmp.getId()));
|
.eq(EdFileInfo::getId, fileInfoTmp.getId()));
|
||||||
|
return destSaveFileInfo;
|
||||||
} else if (strategy == 3) {
|
} else if (strategy == 3) {
|
||||||
// 文件名加“_1”,版本号从100开始
|
// 文件名加“_1”,版本号从100开始
|
||||||
// 处理MySQL相关逻辑
|
// 处理MySQL相关逻辑
|
||||||
|
|
@ -910,8 +926,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String destFileSysPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
String destFileSysPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
||||||
fileSystemService.moveFile(srcFileSysPath, destFileSysPath);
|
fileSystemService.moveFile(srcFileSysPath, destFileSysPath);
|
||||||
this.baseMapper.deleteById(srcFileInfo.getId());
|
this.baseMapper.deleteById(srcFileInfo.getId());
|
||||||
|
return newEdFileInfo;
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.success(true);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -934,13 +951,14 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
EdFileInfo destFolderInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
EdFileInfo destFolderInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getId, targetFolderId));
|
.eq(EdFileInfo::getId, targetFolderId));
|
||||||
|
EdFileInfo destFileInfo = null;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// 没有同名文件
|
// 没有同名文件
|
||||||
// 首先将信息保存到MySQL
|
// 首先将信息保存到MySQL
|
||||||
String fileTime = EleCommonUtil.getNowTimeStr();
|
String fileTime = EleCommonUtil.getNowTimeStr();
|
||||||
String codePathByDbPath = commonService.getCodePathByDbPath(destFolderInfo.getFilePath());
|
String codePathByDbPath = commonService.getCodePathByDbPath(destFolderInfo.getFilePath());
|
||||||
String newFileCode = commonService.createFileCode(codePathByDbPath, srcFileInfo.getFileType(), FILE_START_VERSION, fileTime);
|
String newFileCode = commonService.createFileCode(codePathByDbPath, srcFileInfo.getFileType(), FILE_START_VERSION, fileTime);
|
||||||
EdFileInfo destFileInfo = BeanUtil.copyProperties(srcFileInfo, EdFileInfo.class);
|
destFileInfo = BeanUtil.copyProperties(srcFileInfo, EdFileInfo.class);
|
||||||
destFileInfo.newInit();
|
destFileInfo.newInit();
|
||||||
destFileInfo.setParentId(targetFolderId)
|
destFileInfo.setParentId(targetFolderId)
|
||||||
.setFileVersion(FILE_START_VERSION)
|
.setFileVersion(FILE_START_VERSION)
|
||||||
|
|
@ -953,8 +971,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String destFilePath = commonService.getFileSysPath(destFileInfo.getFilePath(), dataOwnCode);
|
String destFilePath = commonService.getFileSysPath(destFileInfo.getFilePath(), dataOwnCode);
|
||||||
fileSystemService.copyFile(srcFilePath, destFilePath);
|
fileSystemService.copyFile(srcFilePath, destFilePath);
|
||||||
} else {
|
} else {
|
||||||
return handCopyConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
|
destFileInfo = handCopyConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
|
||||||
}
|
}
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "文件 {} 复制到 {},成功,处理文件同名同后缀的方式为 {},最终文件名为 {}", destFileInfo.getFileName() + "." + destFileInfo.getFileName(),
|
||||||
|
commonService.getDbPath(destFolderInfo.getFilePath()), FileRepeatEnum.getDesc(strategy), srcFileInfo.getFileName());
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -990,6 +1010,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
Page<EdFileInfo> edFileInfoPage = this.baseMapper.selectPage(new Page<>(pageNum, pageSize), lambdaQuery);
|
Page<EdFileInfo> edFileInfoPage = this.baseMapper.selectPage(new Page<>(pageNum, pageSize), lambdaQuery);
|
||||||
long total = edFileInfoPage.getTotal();
|
long total = edFileInfoPage.getTotal();
|
||||||
List<UploadRecordDTO> uploadRecordDTOS = BeanUtil.copyToList(edFileInfoPage.getRecords(), UploadRecordDTO.class);
|
List<UploadRecordDTO> uploadRecordDTOS = BeanUtil.copyToList(edFileInfoPage.getRecords(), UploadRecordDTO.class);
|
||||||
|
UserThreadLocal.setSuccessInfo("", "查看了发布管理");
|
||||||
return ElectromagneticResultUtil.success(new UploadRecordVO(total, uploadRecordDTOS));
|
return ElectromagneticResultUtil.success(new UploadRecordVO(total, uploadRecordDTOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1005,15 +1026,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
User singleUser = userMapper.getSingleUser(fileInfo.getCreatedBy());
|
User singleUser = userMapper.getSingleUser(fileInfo.getCreatedBy());
|
||||||
fileInfo.setCreatedBy(singleUser.getUserName());
|
fileInfo.setCreatedBy(singleUser.getUserName());
|
||||||
FileInfoVO fileInfoVO = BeanUtil.copyProperties(fileInfo, FileInfoVO.class);
|
FileInfoVO fileInfoVO = BeanUtil.copyProperties(fileInfo, FileInfoVO.class);
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "查询了文件的详细信息");
|
||||||
return ElectromagneticResultUtil.success(fileInfoVO);
|
return ElectromagneticResultUtil.success(fileInfoVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElectromagneticResult<?> handCopyConflict(String targetFolderId, Integer strategy, EdFileInfo srcFileInfo, EdFileInfo destFolderInfo, int dataOwnCode) {
|
private EdFileInfo handCopyConflict(String targetFolderId, Integer strategy, EdFileInfo srcFileInfo, EdFileInfo destFolderInfo, int dataOwnCode) {
|
||||||
// 禁止同目录下移动和复制
|
// 禁止同目录下移动和复制
|
||||||
if (srcFileInfo.getParentId().equals(destFolderInfo.getId())) {
|
if (srcFileInfo.getParentId().equals(destFolderInfo.getId())) {
|
||||||
String info = "禁止相同文件夹下复制文件";
|
String info = "禁止相同文件夹下复制文件";
|
||||||
log.info(info);
|
log.info(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strategy == 2) {
|
if (strategy == 2) {
|
||||||
|
|
@ -1043,6 +1065,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String srcFilePath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
String srcFilePath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||||
String destFilePath = commonService.getFileSysPath(destSaveFileInfo.getFilePath(), dataOwnCode);
|
String destFilePath = commonService.getFileSysPath(destSaveFileInfo.getFilePath(), dataOwnCode);
|
||||||
fileSystemService.copyFile(srcFilePath, destFilePath);
|
fileSystemService.copyFile(srcFilePath, destFilePath);
|
||||||
|
return destSaveFileInfo;
|
||||||
} else if (strategy == 3) {
|
} else if (strategy == 3) {
|
||||||
// 文件名加“_1”,版本号从100开始
|
// 文件名加“_1”,版本号从100开始
|
||||||
// 处理MySQL相关逻辑
|
// 处理MySQL相关逻辑
|
||||||
|
|
@ -1060,8 +1083,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String srcFileSysPath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
String srcFileSysPath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||||
String destFileSysPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
String destFileSysPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
||||||
fileSystemService.copyFile(srcFileSysPath, destFileSysPath);
|
fileSystemService.copyFile(srcFileSysPath, destFileSysPath);
|
||||||
|
return newEdFileInfo;
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.success(true);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
@ -1209,6 +1233,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.eq(EdFileInfo::getParentId, parentId)
|
.eq(EdFileInfo::getParentId, parentId)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
List<ChildFolderVO> res = BeanUtil.copyToList(edFileInfos, ChildFolderVO.class);
|
List<ChildFolderVO> res = BeanUtil.copyToList(edFileInfos, ChildFolderVO.class);
|
||||||
|
UserThreadLocal.setSuccessInfo(parentId, "查询了子文件集");
|
||||||
return ElectromagneticResultUtil.success(res);
|
return ElectromagneticResultUtil.success(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1239,6 +1264,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
fileName = Base64.encode(fileName.substring(0, fileName.lastIndexOf(".")));
|
fileName = Base64.encode(fileName.substring(0, fileName.lastIndexOf(".")));
|
||||||
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "文件预览成功,文件名为 {}", fileInfo.getFileName() + "." + fileInfo.getFileType());
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
.headers(headers)
|
.headers(headers)
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
fileSystemService.createDirectory(commonService.getEleDataPath(dataOwnCode) + File.separator + prjName);
|
fileSystemService.createDirectory(commonService.getEleDataPath(dataOwnCode) + File.separator + prjName);
|
||||||
UserThreadLocal.setSuccessInfo(newPrjId, "创建 {} 项目成功。", prjName);
|
UserThreadLocal.setSuccessInfo(newPrjId, "创建 {} 项目成功。", prjName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("工程创建失败,具体为--->{}", e.getMessage());
|
String info = StrFormatter.format("工程 {} 创建失败,具体为--->{}", prjName, e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info, e);
|
throw new BizException(info, e);
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +226,9 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
Assert.isTrue(count == 0, StrFormatter.format("该层级目录下存在文件,不允许再定义层级目录。父目录id {},子集名称 {}", parentId, folderName));
|
Assert.isTrue(count == 0, StrFormatter.format("该层级目录下存在文件,不允许再定义层级目录。父目录id {},子集名称 {}", parentId, folderName));
|
||||||
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||||
String folderId = String.valueOf(id + 1);
|
String folderId = String.valueOf(id + 1);
|
||||||
return commonService.addFolder(parentId, folderName, true, folderId, null, dataOwnCode);
|
ElectromagneticResult<?> electromagneticResult = commonService.addFolder(parentId, folderName, true, folderId, null, dataOwnCode);
|
||||||
|
UserThreadLocal.setSuccessInfo(electromagneticResult.getData() + "", "添加子集 {} 成功", folderName);
|
||||||
|
return electromagneticResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -285,9 +287,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> publish(String prjId, int dataOwnCode) {
|
public ElectromagneticResult<?> publish(String prjId, int dataOwnCode) {
|
||||||
|
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectById(prjId);
|
EdFileInfo fileInfo = this.baseMapper.selectById(prjId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String currentUserId = UserThreadLocal.getUserId();
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
|
@ -409,7 +409,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
String targetSysFilePath = commonService.getFileSysPath(targetFile.getFilePath(), dataOwnCode);
|
String targetSysFilePath = commonService.getFileSysPath(targetFile.getFilePath(), dataOwnCode);
|
||||||
needSavePaths.add(targetSysFilePath);
|
needSavePaths.add(targetSysFilePath);
|
||||||
} else {
|
} else {
|
||||||
String info = "存在相同子集";
|
String info = StrFormatter.format("层级沿用失败,源工程 {},目标工程 {},原因 存在相同子集", sourceId, targetId);
|
||||||
log.error(info);
|
log.error(info);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
@ -418,9 +418,10 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
for (String path : needSavePaths) {
|
for (String path : needSavePaths) {
|
||||||
fileSystemService.createDirectory(path);
|
fileSystemService.createDirectory(path);
|
||||||
}
|
}
|
||||||
|
UserThreadLocal.setSuccessInfo(targetId, "层级沿用成功");
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("层级沿用失败");
|
String info = StrFormatter.format("层级沿用失败,源工程 {},目标工程 {},原因 {}", sourceId, targetId, e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +442,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
try {
|
try {
|
||||||
String parentId = this.baseMapper.selectById(id).getParentId();
|
String parentId = this.baseMapper.selectById(id).getParentId();
|
||||||
// 首先检查同层是否有同名目录
|
// 首先检查同层是否有同名目录
|
||||||
Assert.isTrue(commonService.notExistSameFolder(parentId, newFolderName, dataOwnCode), "子集名已经存在");
|
Assert.isTrue(commonService.notExistSameFolder(parentId, newFolderName, dataOwnCode), StrFormatter.format("{} 子集名已经存在", newFolderName));
|
||||||
String currentUserId = UserThreadLocal.getUserId();
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
|
@ -453,9 +454,10 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
.eq(EdFileInfo::getId, id)
|
.eq(EdFileInfo::getId, id)
|
||||||
.set(EdFileInfo::getFileName, newFolderName));
|
.set(EdFileInfo::getFileName, newFolderName));
|
||||||
fileSystemService.renameFile(sysFilePath, newFolderName);
|
fileSystemService.renameFile(sysFilePath, newFolderName);
|
||||||
|
UserThreadLocal.setSuccessInfo(id, "子集名称 {} 修改成功", newFolderName);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("修改子集名称为{}失败", newFolderName);
|
String info = StrFormatter.format("修改子集名称为 {} 失败", newFolderName);
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue