文件相关操作的日志新增路径。
This commit is contained in:
parent
dbeccc65df
commit
ac8277f959
|
|
@ -33,7 +33,7 @@ public class FileRecycleQueryVO {
|
|||
|
||||
private String dataOwner;
|
||||
|
||||
private int dataOwnCode;
|
||||
private int dataOwn;
|
||||
|
||||
private String filePath;
|
||||
|
||||
|
|
|
|||
|
|
@ -181,9 +181,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return ElectromagneticResultUtil.fail("-1", "没有操作权限。");
|
||||
}
|
||||
}
|
||||
|
||||
ElectromagneticResult<?> res = commonService.addFolder(createFolderDTO.getParentId(), createFolderDTO.getNewFolderName(), false, folderId, createFolderDTO.getFileNote(), dataOwnCode);
|
||||
UserThreadLocal.setSuccessInfo(createFolderDTO.getParentId(), res.getData() + "", "创建文件夹 {} 成功", createFolderDTO.getNewFolderName());
|
||||
String dbPath = commonService.getDbPath(this.baseMapper.selectById(createFolderDTO.getParentId()).getFilePath());
|
||||
UserThreadLocal.setSuccessInfo(createFolderDTO.getParentId(), res.getData() + "", "创建文件夹 {} 成功,路径为 {}", createFolderDTO.getNewFolderName(), dbPath);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -245,16 +245,17 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
public ElectromagneticResult<?> delete(String id, int dataOwnCode) {
|
||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
||||
if (fileInfo.getDataType() == EleDataTypeEnum.FOLDER.code) {
|
||||
ElectromagneticResult<?> res = commonService.deleteFolder(id, dataOwnCode);
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废目录 {} 成功", fileInfo.getFileName());
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废目录 {} 成功,路径为 {}", fileInfo.getFileName(), dbPath);
|
||||
return res;
|
||||
}
|
||||
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getEffectFlag, false)
|
||||
.set(EdFileInfo::getAllDeleted, true)
|
||||
.eq(EdFileInfo::getFileId, fileInfo.getFileId()));
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废文件 {}.{} 成功", fileInfo.getFileName(), fileInfo.getFileType());
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废文件 {}.{} 成功,路径为 {}", fileInfo.getFileName(), fileInfo.getFileType(), dbPath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
|
|
@ -267,10 +268,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
public ResponseEntity<InputStreamResource> download(String id, HttpServletResponse response, int dataOwnCode) {
|
||||
String fileName = "";
|
||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||
String fileSysPath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
||||
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
||||
try {
|
||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||
String fileSysPath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
||||
Assert.isTrue(FileUtil.exist(fileSysPath), "下载文件不存在。");
|
||||
Assert.isTrue(FileUtil.exist(fileSysPath), "下载文件不存在,路径为 {}", dbPath);
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(fileSysPath);
|
||||
fileName = fileSystemResource.getFilename();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
|
@ -279,7 +281,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
headers.add("Expires", "0");
|
||||
String newFileName = Base64.encode(fileName.substring(0, fileName.lastIndexOf(".")));
|
||||
response.setHeader("content-disposition", "attachment;filename=" + newFileName);
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), fileInfo.getFileId(), "下载文件 {} 成功", fileName);
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), fileInfo.getFileId(), "下载文件 {} 成功,文件路径 {}", fileName, dbPath);
|
||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
|
|
@ -288,7 +290,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
|
||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("下载文件异常 {}", fileName);
|
||||
String info = StrFormatter.format("下载文件异常 {},路径 {}", fileName, dbPath);
|
||||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
|
|
@ -338,13 +340,14 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
}
|
||||
|
||||
String srcFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
||||
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
||||
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getId, updateFileInfoDTO.getId())
|
||||
.set(EdFileInfo::getFileName, updateFileInfoDTO.getFileName())
|
||||
.set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote()));
|
||||
String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
|
||||
fileSystemService.renameFile(srcFilePath, newName);
|
||||
UserThreadLocal.setSuccessInfo(commonService.getLastPrjLeafId(fileInfo.getFilePath()), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}.{},新备注为 {}", newFileName, fileInfo.getFileType(), updateFileInfoDTO.getFileNote());
|
||||
UserThreadLocal.setSuccessInfo(commonService.getLastPrjLeafId(fileInfo.getFilePath()), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}.{},新备注为 {},路径为 {}", newFileName, fileInfo.getFileType(), updateFileInfoDTO.getFileNote(), dbPath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("更新文件信息失败,新文件名 {}, 原因 {}", newFileName, e.getMessage());
|
||||
|
|
@ -377,7 +380,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), fileId, "回退版本成功,新版本为 {}", targetVersion);
|
||||
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
||||
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), fileId, "回退版本成功,新版本为 {},路径为 {}", targetVersion, dbPath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
Map<String, String> filesPath = commonService.getFilesPath(filePaths);
|
||||
Map<String, String> userIdNameMap = getUserIdNameMap(records.stream().map(FileRecycleQueryVO::getUpdatedBy).collect(Collectors.toList()));
|
||||
records.forEach(e -> {
|
||||
e.setDataOwner(DataOwnEnum.getTypeByCode(e.getDataOwnCode()));
|
||||
e.setDataOwner(DataOwnEnum.getTypeByCode(e.getDataOwn()));
|
||||
e.setFilePrjPath(filesPath.get(e.getFilePath()));
|
||||
e.setFileSizeShow(EleCommonUtil.convertFileSize(e.getFileSize()));
|
||||
e.setUserName(userIdNameMap.get(e.getUpdatedBy()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue