修改备份的问题。
This commit is contained in:
parent
997bef0b3b
commit
791fe905cc
|
|
@ -11,8 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/ed/backup/")
|
@RequestMapping("/data/ed/backup/")
|
||||||
public class FileBackupLogController {
|
public class FileBackupLogController {
|
||||||
|
|
@ -29,7 +27,7 @@ public class FileBackupLogController {
|
||||||
@GetMapping(value = "restore")
|
@GetMapping(value = "restore")
|
||||||
@UserOperation(value = "系统恢复", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
@UserOperation(value = "系统恢复", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||||
public ElectromagneticResult<?> restore() {
|
public ElectromagneticResult<?> restore() {
|
||||||
List<String> restorePaths = fileBackLogService.restore();
|
Long maxEndTime = fileBackLogService.restore();
|
||||||
return ElectromagneticResultUtil.success(restorePaths);
|
return ElectromagneticResultUtil.success(maxEndTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@ package com.electromagnetic.industry.software.manage.service;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface FileBackLogService {
|
public interface FileBackLogService {
|
||||||
|
|
||||||
ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize);
|
ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize);
|
||||||
|
|
||||||
List<String> restore();
|
Long restore();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1115,7 +1115,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
UserThreadLocal.setSuccessInfo("", "", "查看发布管理成功");
|
UserThreadLocal.setSuccessInfo("", "", "查看发布管理成功");
|
||||||
return ElectromagneticResultUtil.success(new UploadRecordVO(0, new ArrayList<>()));
|
return ElectromagneticResultUtil.success(new UploadRecordVO(0, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
lambdaQuery.or(qr -> {
|
lambdaQuery.or(qr -> {
|
||||||
for (String id : list) {
|
for (String id : list) {
|
||||||
qr.likeRight(EdFileInfo::getFileCode, id);
|
qr.likeRight(EdFileInfo::getFileCode, id);
|
||||||
|
|
@ -1253,7 +1252,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
if (file.getId().length() < 6) {
|
if (file.getId().length() < 6) {
|
||||||
throw new StringIndexOutOfBoundsException("此文件的FILE_CODE小于六位:" + id);
|
throw new StringIndexOutOfBoundsException("此文件的FILE_CODE小于六位:" + id);
|
||||||
}
|
}
|
||||||
if (file.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code) || file.getDataOwn().equals(DataOwnEnum.USER_PRJ.code)) {
|
if (DataOwnEnum.isPrjCode(file.getDataOwn())) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
return file.getFileCode().substring(0, 6);
|
return file.getFileCode().substring(0, 6);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
@ -80,12 +78,11 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> restore() {
|
public Long restore() {
|
||||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||||
.eq(EdFileInfo::getPermanentDeleted, false)
|
.eq(EdFileInfo::getPermanentDeleted, false)
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
||||||
List<String> restoreFilePaths = new ArrayList<>();
|
|
||||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||||
|
|
||||||
String destPath = EleCommonUtil.simpleTrueFalse(DataOwnEnum.isUserCode(edFileInfo.getDataOwn()),
|
String destPath = EleCommonUtil.simpleTrueFalse(DataOwnEnum.isUserCode(edFileInfo.getDataOwn()),
|
||||||
|
|
@ -97,11 +94,15 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
|
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());
|
||||||
restoreFilePaths.add(dbPath);
|
|
||||||
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "{} 恢复成功,路径为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), dbPath);
|
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "{} 恢复成功,路径为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), dbPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功");
|
List<FileBackupLog> fileBackupLogs = this.baseMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery().orderByDesc(FileBackupLog::getEndTime).last(" limit 1"));
|
||||||
return restoreFilePaths;
|
if (CollUtil.isEmpty(fileBackupLogs)) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
Long endTime = fileBackupLogs.get(0).getEndTime();
|
||||||
|
UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功,最新时间戳为 {}", endTime);
|
||||||
|
return endTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue