去掉uuid
This commit is contained in:
parent
cb4cfe1618
commit
e1e6e9f466
|
|
@ -65,8 +65,8 @@ public class FileController {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@RequestMapping("/download")
|
@RequestMapping("/download")
|
||||||
public ResponseEntity<InputStreamResource> download(@RequestParam("id") String id, @RequestParam("uuid") String uuid) throws Exception {
|
public ResponseEntity<InputStreamResource> download(@RequestParam("id") String id) throws Exception {
|
||||||
return fileService.download(id, uuid);
|
return fileService.download(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/backupSql")
|
@RequestMapping("/backupSql")
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public interface FileService {
|
||||||
|
|
||||||
// void remove(String id);
|
// void remove(String id);
|
||||||
|
|
||||||
ResponseEntity<InputStreamResource> download(String id, String uuid) throws Exception;
|
ResponseEntity<InputStreamResource> download(String id) throws Exception;
|
||||||
|
|
||||||
void backupSql(MultipartFile file) throws Exception;
|
void backupSql(MultipartFile file) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ public class FileServiceImpl implements FileService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<InputStreamResource> download(String id, String uuid) throws Exception {
|
public ResponseEntity<InputStreamResource> download(String id) throws Exception {
|
||||||
String destPath = getFileSysPathById(id + "_" + uuid);
|
String destPath = getFileSysPathById(id);
|
||||||
FileSystemResource fileSystemResource = new FileSystemResource(destPath);
|
FileSystemResource fileSystemResource = new FileSystemResource(destPath);
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
|
|
|
||||||
|
|
@ -125,9 +125,6 @@ public class EdFileInfo extends BaseModel {
|
||||||
@TableField(value = "permanent_deleted")
|
@TableField(value = "permanent_deleted")
|
||||||
private Boolean permanentDeleted;
|
private Boolean permanentDeleted;
|
||||||
|
|
||||||
@TableField(value = "uuid")
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
public void newInit() {
|
public void newInit() {
|
||||||
String userId = UserThreadLocal.getUserId();
|
String userId = UserThreadLocal.getUserId();
|
||||||
String newFileDbId = IdWorker.getSnowFlakeIdString();
|
String newFileDbId = IdWorker.getSnowFlakeIdString();
|
||||||
|
|
@ -141,6 +138,5 @@ public class EdFileInfo extends BaseModel {
|
||||||
this.setCreatedBy(userId);
|
this.setCreatedBy(userId);
|
||||||
this.setFileId(newFileDbId);
|
this.setFileId(newFileDbId);
|
||||||
this.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
this.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
||||||
this.setUuid(IdUtil.fastSimpleUUID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,16 +138,13 @@ public class CommonService {
|
||||||
|
|
||||||
public String getFileSysPath(String id) {
|
public String getFileSysPath(String id) {
|
||||||
EdFileInfo fileInfo = edFileInfoMapper.selectById(id);
|
EdFileInfo fileInfo = edFileInfoMapper.selectById(id);
|
||||||
String uuid = fileInfo.getUuid();
|
|
||||||
String fileType = fileInfo.getFileType();
|
|
||||||
int dataOwnCode = fileInfo.getDataOwn();
|
int dataOwnCode = fileInfo.getDataOwn();
|
||||||
DataOwnEnum enumByCode = DataOwnEnum.getEnumByCode(dataOwnCode);
|
DataOwnEnum enumByCode = DataOwnEnum.getEnumByCode(dataOwnCode);
|
||||||
String fileName = id + MYSQL_FILE_PATH_SPLIT + uuid + "." + fileType;
|
|
||||||
String filePath;
|
String filePath;
|
||||||
switch (Objects.requireNonNull(enumByCode)) {
|
switch (Objects.requireNonNull(enumByCode)) {
|
||||||
case SYS_FILE, SYS_PRJ, REPO_PRJ, REPO_FILE -> filePath = getPrjRootPath1(dataOwnCode) + fileName;
|
case SYS_FILE, SYS_PRJ, REPO_PRJ, REPO_FILE -> filePath = getPrjRootPath1(dataOwnCode) + id;
|
||||||
case USER_FILE, USER_PRJ ->
|
case USER_FILE, USER_PRJ ->
|
||||||
filePath = getPrjRootPath1(dataOwnCode) + fileInfo.getCreatedBy() + File.separator + fileName;
|
filePath = getPrjRootPath1(dataOwnCode) + fileInfo.getCreatedBy() + File.separator + id;
|
||||||
default -> throw new BizException("参数错误");
|
default -> throw new BizException("参数错误");
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
|
|
|
||||||
|
|
@ -945,7 +945,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String codePathByDbPath = commonService.getCodePathByDbPath(parentFolderInfo.getFilePath());
|
String codePathByDbPath = commonService.getCodePathByDbPath(parentFolderInfo.getFilePath());
|
||||||
String fileCode = commonService.createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, newEdFileInfo.getFileTime());
|
String fileCode = commonService.createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, newEdFileInfo.getFileTime());
|
||||||
newEdFileInfo.setParentId(parentId)
|
newEdFileInfo.setParentId(parentId)
|
||||||
.setUuid(IdUtil.simpleUUID())
|
|
||||||
.setFileCode(fileCode)
|
.setFileCode(fileCode)
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
.setDataOwn(dataOwnCode)
|
.setDataOwn(dataOwnCode)
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
destPath = destPath.replace("//", "/");
|
destPath = destPath.replace("//", "/");
|
||||||
log.info("back up file path is {}", destPath);
|
log.info("back up file path is {}", destPath);
|
||||||
if (!FileUtil.exist(destPath)) {
|
if (!FileUtil.exist(destPath)) {
|
||||||
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId(), edFileInfo.getUuid());
|
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
|
||||||
FileUtil.writeBytes(bytes, destPath);
|
FileUtil.writeBytes(bytes, destPath);
|
||||||
String dbPath = commonService.getDbPath(edFileInfo.getFilePath());
|
String dbPath = commonService.getDbPath(edFileInfo.getFilePath());
|
||||||
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "{} 恢复成功,路径为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), dbPath);
|
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "{} 恢复成功,路径为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), dbPath);
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ public class BackupHandler {
|
||||||
// return JSONUtil.toBean(data, BackupFileResLog.class);
|
// return JSONUtil.toBean(data, BackupFileResLog.class);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public byte[] downloadFile(String id, String uuid) {
|
public byte[] downloadFile(String id) {
|
||||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/download?id={}&&uuid=", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort(), id, uuid);
|
String url = StrFormatter.format("http://{}:{}/data/file/backup/download?id={}", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort(), id);
|
||||||
return HttpUtil.downloadBytes(url);
|
return HttpUtil.downloadBytes(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue