refactor(dataset): 优化数据集路径管理和关联关系处理

- 移除Dataset类中initCreateParam方法的parentPath参数
- 简化handleParentChange方法中的路径构建逻辑
- 更新错误消息将"子数据集"改为"关联数据集"
- 修改前端界面将"父数据集"相关术语统一为"关联数据集"
- 在导入配置组件中添加类型定义和改进文件处理逻辑
- 限制数据源选项排除COLLECTION类型避免错误选择
This commit is contained in:
2026-01-30 16:48:39 +08:00
parent accaa47a83
commit bd37858ccc
7 changed files with 101 additions and 71 deletions

View File

@@ -73,7 +73,7 @@ public class DatasetApplicationService {
Dataset dataset = DatasetConverter.INSTANCE.convertToDataset(createDatasetRequest);
Dataset parentDataset = resolveParentDataset(createDatasetRequest.getParentDatasetId(), dataset.getId());
dataset.setParentDatasetId(parentDataset == null ? null : parentDataset.getId());
dataset.initCreateParam(datasetBasePath, parentDataset == null ? null : parentDataset.getPath());
dataset.initCreateParam(datasetBasePath);
// 处理标签
Set<Tag> processedTags = Optional.ofNullable(createDatasetRequest.getTags())
.filter(CollectionUtils::isNotEmpty)
@@ -291,7 +291,9 @@ public class DatasetApplicationService {
private void handleParentChange(Dataset dataset, String parentDatasetId) {
String normalized = normalizeParentId(parentDatasetId);
if (Objects.equals(dataset.getParentDatasetId(), normalized)) {
String expectedPath = buildDatasetPath(datasetBasePath, dataset.getId());
if (Objects.equals(dataset.getParentDatasetId(), normalized)
&& Objects.equals(dataset.getPath(), expectedPath)) {
return;
}
long childCount = datasetRepository.countByParentId(dataset.getId());
@@ -299,8 +301,7 @@ public class DatasetApplicationService {
throw BusinessException.of(DataManagementErrorCode.DATASET_HAS_CHILDREN);
}
Dataset parent = normalized == null ? null : resolveParentDataset(normalized, dataset.getId());
String newPath = buildDatasetPath(parent == null ? datasetBasePath : parent.getPath(), dataset.getId());
moveDatasetPath(dataset, newPath);
moveDatasetPath(dataset, expectedPath);
dataset.setParentDatasetId(parent == null ? null : parent.getId());
}

View File

@@ -114,9 +114,9 @@ public class Dataset extends BaseEntity<String> {
this.updatedAt = LocalDateTime.now();
}
public void initCreateParam(String datasetBasePath, String parentPath) {
public void initCreateParam(String datasetBasePath) {
this.id = UUID.randomUUID().toString();
String basePath = normalizeBasePath(parentPath != null && !parentPath.isBlank() ? parentPath : datasetBasePath);
String basePath = normalizeBasePath(datasetBasePath);
this.path = basePath + File.separator + this.id;
if (this.status == null) {
this.status = DatasetStatusType.DRAFT;

View File

@@ -42,9 +42,9 @@ public enum DataManagementErrorCode implements ErrorCode {
*/
DIRECTORY_NOT_FOUND("data_management.0007", "目录不存在"),
/**
* 存在数据集
* 存在关联数据集
*/
DATASET_HAS_CHILDREN("data_management.0008", "存在数据集,禁止删除或移动"),
DATASET_HAS_CHILDREN("data_management.0008", "存在关联数据集,禁止删除或移动"),
/**
* 数据集文件不存在
*/