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