优化代码,修改文件备份的bug
This commit is contained in:
parent
8043e8055d
commit
d247fda266
|
|
@ -46,7 +46,6 @@ import java.io.IOException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
@ -73,7 +72,7 @@ public class ChatService {
|
|||
.in(AiFileUploadRecord::getId, ids))
|
||||
.stream()
|
||||
.map(AiFileUploadRecord::getVectorId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
Optional<Boolean> delete = vectorStore.delete(vectorIds);
|
||||
if (delete.isPresent() && ObjectUtil.equals(delete.get(), true)) {
|
||||
aiFileUploadRecordMapper.update(Wrappers.lambdaUpdate(AiFileUploadRecord.class)
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code)
|
||||
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).toList();
|
||||
}
|
||||
Map<Integer, List<String>> map;
|
||||
if (querySource == PrjQuerySource.SYS_DB.value) {
|
||||
|
|
@ -414,7 +414,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.stream()
|
||||
.map(e -> e.replace(UPLOAD_FILE_CHUNK_SUFFIX, ""))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1482,7 +1482,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
queryWrapper.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getSaveStatus, EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
fileIds = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getFileId).collect(Collectors.toList());
|
||||
fileIds = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getFileId).toList();
|
||||
} else {
|
||||
LambdaQueryWrapper<EdFileFavorite> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(EdFileFavorite::getFileId).eq(EdFileFavorite::getUserId, userId);
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
.select(EdFileInfo::getId)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||
List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).toList();
|
||||
ids.add(prjId);
|
||||
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids));
|
||||
// 对原文件进行处理
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
FileTagInfo info = new FileTagInfo();
|
||||
BeanUtils.copyProperties(tag, info);
|
||||
return info;
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
|||
return ElectromagneticResultUtil.success(new RespPageVO<>(0L, records));
|
||||
}
|
||||
|
||||
List<String> fileIds = records.stream().map(FileBackupLog::getFileId).collect(Collectors.toList());
|
||||
List<String> fileIds = records.stream().map(FileBackupLog::getFileId).toList();
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.<EdFileInfo>lambdaQuery()
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.in(EdFileInfo::getId, fileIds));
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
long total = edFileInfoPage.getTotal();
|
||||
List<FileRecycleQueryVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileRecycleQueryVO.class);
|
||||
|
||||
List<String> filePaths = records.stream().map(FileRecycleQueryVO::getFilePath).collect(Collectors.toList());
|
||||
List<String> filePaths = records.stream().map(FileRecycleQueryVO::getFilePath).toList();
|
||||
Map<String, String> filesPath = commonService.getFilesPath(filePaths);
|
||||
Map<String, String> userIdNameMap = getUserIdNameMap(records.stream().map(FileRecycleQueryVO::getUpdatedBy).collect(Collectors.toList()));
|
||||
Map<String, String> userIdNameMap = getUserIdNameMap(records.stream().map(FileRecycleQueryVO::getUpdatedBy).toList());
|
||||
records.forEach(e -> {
|
||||
e.setDataOwner(DataOwnEnum.getTypeByCode(e.getDataOwn()));
|
||||
e.setFilePrjPath(filesPath.get(e.getFilePath()));
|
||||
|
|
|
|||
|
|
@ -118,6 +118,6 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
|
|||
return relations.stream()
|
||||
.map(FileTagRelation::getFileId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
queryWrapper.eq(UserRole::getUserId, userId);
|
||||
List<String> roleIds = Optional.ofNullable(userRoleMapper.selectList(queryWrapper))
|
||||
.orElse(Collections.emptyList())
|
||||
.stream().map(UserRole::getRoleId).collect(Collectors.toList());
|
||||
.stream().map(UserRole::getRoleId).toList();
|
||||
|
||||
if (roleIds.isEmpty()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
|
||||
List<RolePermission> permissionsToDelete = oldPermissions.stream()
|
||||
.filter(p -> !newPermissionSet.contains(p.getRoleId() + "_" + p.getPermissionCode()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
log.info("删除旧权限: {}", permissionsToDelete);
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
if (!permissionsToDelete.isEmpty()) {
|
||||
List<String> idsToDelete = permissionsToDelete.stream()
|
||||
.map(RolePermission::getId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
this.removeBatchByIds(idsToDelete);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
// 找到所有的根节点
|
||||
List<RolePermissionDTO> rootNodes = nodes.stream()
|
||||
.filter(node -> node.getParentId().equals(PRJ_PARENT_ID))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
// 递归设置子节点
|
||||
for (RolePermissionDTO rootNode : rootNodes) {
|
||||
|
|
@ -359,7 +359,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
return nodes.stream()
|
||||
.filter(node -> parent.getId().equals(node.getParentId())) // 匹配父子关系
|
||||
.peek(node -> node.setChildren(findChildren(node, nodes))) // 递归设置子节点
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
|
|||
|
||||
private void setOtherInfo(List<AccessLogQueryVO> res) {
|
||||
|
||||
List<String> userIds = res.stream().map(AccessLogQueryVO::getUserId).collect(Collectors.toList());
|
||||
List<String> userIds = res.stream().map(AccessLogQueryVO::getUserId).toList();
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public class BackupTask {
|
|||
List<FileBackupLog> fileBackupLogs = fileBackupLogMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery()
|
||||
.select(FileBackupLog::getFileId)
|
||||
.eq(FileBackupLog::isBackupSuccess, false));
|
||||
return fileBackupLogs.stream().map(FileBackupLog::getFileId).collect(Collectors.toList());
|
||||
return fileBackupLogs.stream().map(FileBackupLog::getFileId).toList();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
|
|
@ -190,7 +190,7 @@ public class BackupTask {
|
|||
List<FileBackupLog> fileBackupLogs = fileBackupLogMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery()
|
||||
.eq(FileBackupLog::getFileName, fileName)
|
||||
.eq(FileBackupLog::getSource, FileBackupSource.SQL.code));
|
||||
List<FileBackupLog> successBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).collect(Collectors.toList());
|
||||
List<FileBackupLog> successBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).toList();
|
||||
if (CollUtil.isNotEmpty(successBacks)) {
|
||||
log.info("最新的SQL文件已经备份过。");
|
||||
return;
|
||||
|
|
@ -199,7 +199,7 @@ public class BackupTask {
|
|||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog resLog = backupHandler.backupSql(maxModifyTimeFile.getAbsolutePath());
|
||||
long endTime = System.currentTimeMillis();
|
||||
List<FileBackupLog> failBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).collect(Collectors.toList());
|
||||
List<FileBackupLog> failBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).toList();
|
||||
if (CollUtil.isEmpty(failBacks)) {
|
||||
FileBackupLog backupLog = new FileBackupLog()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
|
|
|
|||
Loading…
Reference in New Issue