数据集生命周期版本2.0
This commit is contained in:
6
pom.xml
6
pom.xml
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.4.5</version>
|
||||
<version>3.2.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.bipt</groupId>
|
||||
@ -27,7 +27,7 @@
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>24</java.version>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -2,5 +2,5 @@ package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
public class MessageConstant {
|
||||
public static final String UNKNOWN_ERROR = "未知错误";
|
||||
public static final String ALREADY_EXISTS = "数据集已存在";
|
||||
public static final String ALREADY_EXISTS = "已存在";
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
/**
|
||||
* 状态常量,启用或者禁用
|
||||
* @author hky
|
||||
*/
|
||||
public class StatusConstant {
|
||||
//启用
|
||||
public static final Integer ENABLE = 1;
|
||||
|
||||
//禁用
|
||||
public static final Integer DISABLE = 0;
|
||||
}
|
@ -2,12 +2,14 @@ package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="数据集相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/dataset")
|
||||
@Slf4j
|
||||
@ -20,6 +22,7 @@ public class DatasetController {
|
||||
* @param datasetDTO
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary ="新增数据集")
|
||||
@PostMapping
|
||||
public OptResult save(@RequestBody DatasetDTO datasetDTO) {
|
||||
log.info("新增数据集:{}", datasetDTO);
|
||||
@ -32,6 +35,7 @@ public class DatasetController {
|
||||
* @param dataSetPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary ="分页查询")
|
||||
@GetMapping("/page")
|
||||
public OptResult<PageResult> page(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||
log.info("数据集分页查询:{}", dataSetPageQueryDTO);
|
||||
@ -45,6 +49,7 @@ public class DatasetController {
|
||||
* @param datasetDTO
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary ="修改数据集")
|
||||
@PutMapping
|
||||
public OptResult update(@RequestBody DatasetDTO datasetDTO){
|
||||
log.info("修改数据集",datasetDTO);
|
||||
@ -59,6 +64,7 @@ public class DatasetController {
|
||||
* @param datasetIds 数据集ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Operation(summary ="删除数据集")
|
||||
@DeleteMapping
|
||||
public OptResult<String> deleteBatch(@RequestBody List<Long> datasetIds) {
|
||||
log.info("批量删除数据集,ID列表:{}", datasetIds);
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum DatasetType {
|
||||
UPLOAD(0,"用户上传"),
|
||||
FROM_DATABASE(1,"来源于数据库");
|
||||
|
||||
private final Integer code;
|
||||
private final String description;
|
||||
|
||||
DatasetType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态码获取对应的枚举值
|
||||
* @param code 状态码
|
||||
* @return 对应的枚举值
|
||||
*/
|
||||
public static DatasetType fromCode(Integer code) {
|
||||
for (DatasetType datasetType : DatasetType.values()) {
|
||||
if (datasetType.getCode().equals(code)) {
|
||||
return datasetType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("无效的数据集状态码: " + code);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.StatusConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.DatasetMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||
@ -15,6 +17,8 @@ import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType.FROM_DATABASE;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DatasetServiceImpl implements DatasetService {
|
||||
@ -29,20 +33,26 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
@Transactional
|
||||
public void save(DatasetDTO datasetDTO) {
|
||||
//判断数据集类型,如果是本地上传则保存,若用调用数据仓库进入下一步
|
||||
if (datasetDTO.getDatasetType()==0){
|
||||
//TODO 保存到分布式文件系统
|
||||
// 获取数据集类型
|
||||
DatasetType datasetType = DatasetType.fromCode(datasetDTO.getDatasetType());
|
||||
// 根据类型处理数据
|
||||
switch (datasetType) {
|
||||
case UPLOAD:
|
||||
//TODO 保存到分布式文件系统
|
||||
break;
|
||||
case FROM_DATABASE:
|
||||
String args = datasetDTO.getArgs();
|
||||
//TODO 根据筛选条件调用数据仓库中的数据
|
||||
|
||||
}else {
|
||||
// Map<String,String> args = datasetDTO.getArgs();
|
||||
String args = datasetDTO.getArgs();
|
||||
int datasetType = datasetDTO.getDatasetType();
|
||||
//TODO 根据筛选条件调用数据仓库中的数据
|
||||
|
||||
//TODO 调用数据仓库保存到分布式文件系统
|
||||
//TODO 调用数据仓库保存到分布式文件系统
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("不支持的数据集类型: " + datasetType);
|
||||
}
|
||||
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||
datasetEntity.setDatasetStatus(1);
|
||||
datasetEntity.setDatasetStatus(StatusConstant.ENABLE);
|
||||
datasetEntity.setCreateTime(LocalDateTime.now());
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
datasetMapper.insert(datasetEntity);
|
||||
@ -59,15 +69,18 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
public void update(DatasetDTO datasetDTO) {
|
||||
/*DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);*/
|
||||
if (datasetDTO.getDatasetType()==0){
|
||||
//TODO 覆盖保存到分布式文件系统中
|
||||
|
||||
}else {
|
||||
//TODO 覆盖数据文件
|
||||
|
||||
|
||||
//TODO
|
||||
DatasetType datasetType = DatasetType.fromCode(datasetDTO.getDatasetType());
|
||||
// 根据类型处理数据
|
||||
switch (datasetType) {
|
||||
case UPLOAD:
|
||||
//TODO 覆盖保存到分布式文件系统中
|
||||
break;
|
||||
case FROM_DATABASE:
|
||||
//TODO 覆盖数据文件
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("不支持的数据集类型: " + datasetType);
|
||||
}
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||
@ -94,14 +107,7 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteBatch(List<Long> datasetIds) {
|
||||
for (Long datasetId : datasetIds) {
|
||||
DatasetEntity datasetEntity = datasetMapper.getById(datasetId);
|
||||
if (datasetEntity == null) {
|
||||
throw new IllegalArgumentException("数据集不存在,ID:" + datasetId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//TODO 在分布式文件系统中删除
|
||||
datasetMapper.deleteBatch(datasetIds);
|
||||
}
|
||||
|
Reference in New Issue
Block a user