优化文件恢复

This commit is contained in:
chenxudong 2025-03-25 17:19:38 +08:00
parent 9b2698d919
commit 9da19d7e4e
3 changed files with 23 additions and 10 deletions

View File

@ -0,0 +1,11 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class OperationModuleVO {
private String text;
private String value;
}

View File

@ -66,9 +66,13 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
.eq(EdFileInfo::getPermanentDeleted, false) .eq(EdFileInfo::getPermanentDeleted, false)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code)); .eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
for (EdFileInfo edFileInfo : edFileInfos) { for (EdFileInfo edFileInfo : edFileInfos) {
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
String destPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn()); String destPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
FileUtil.writeBytes(bytes, destPath); if (!FileUtil.exist(destPath)) {
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);
}
} }
UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功"); UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功");
} }

View File

@ -17,16 +17,14 @@ import com.electromagnetic.industry.software.manage.pojo.models.User;
import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog; import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog;
import com.electromagnetic.industry.software.manage.pojo.req.AccessLogQueryDTO; import com.electromagnetic.industry.software.manage.pojo.req.AccessLogQueryDTO;
import com.electromagnetic.industry.software.manage.pojo.resp.AccessLogQueryVO; import com.electromagnetic.industry.software.manage.pojo.resp.AccessLogQueryVO;
import com.electromagnetic.industry.software.manage.pojo.resp.OperationModuleVO;
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO; import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
import com.electromagnetic.industry.software.manage.service.UserAccessLogService; import com.electromagnetic.industry.software.manage.service.UserAccessLogService;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -79,13 +77,13 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
@Override @Override
public ElectromagneticResult<?> operationModule() { public ElectromagneticResult<?> operationModule() {
Map<String, String> map = new HashMap<>(); List<OperationModuleVO> res = new ArrayList<>();
for (UserOperationModuleEnum e : UserOperationModuleEnum.values()) { for (UserOperationModuleEnum e : UserOperationModuleEnum.values()) {
map.put(e.key, e.desc); OperationModuleVO vo = new OperationModuleVO().setText(e.desc).setValue(e.key);
res.add(vo);
} }
return ElectromagneticResultUtil.success(map); return ElectromagneticResultUtil.success(res);
} }
private void setOtherInfo(List<AccessLogQueryVO> res) { private void setOtherInfo(List<AccessLogQueryVO> res) {