数据集新增及修改功能版本1.0

This commit is contained in:
2025-05-13 21:36:29 +08:00
parent 23be873a7c
commit b953e85704
11 changed files with 287 additions and 0 deletions

11
pom.xml
View File

@ -54,6 +54,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,43 @@
package com.bipt.intelligentapplicationorchestrationservice.controller;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetDTO;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/dataset")
@Slf4j
public class DatasetController {
@Autowired
private DatasetService datasetService;
/**
* 新增数据集
* @param datasetDTO
* @return
*/
@PostMapping
public OptResult save(@RequestBody DatasetDTO datasetDTO) {
log.info("新增数据集:{}", datasetDTO);
datasetService.save(datasetDTO);
return OptResult.success();
}
/**
* 修改数据集
* @param datasetEntity
* @return
*/
@PutMapping
public OptResult update(@RequestBody DatasetEntity datasetEntity){
log.info("修改数据集",datasetEntity);
datasetService.update(datasetEntity);
return OptResult.success();
}
}

View File

@ -0,0 +1,27 @@
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
import org.apache.ibatis.annotations.Delete;
/**
* 数据库操作类型
*/
public enum OperationType {
/**
* 更新操作
*/
UPDATE,
/**
* 插入操作
*/
INSERT,
/**
* 删除操作
*/
DELETE,
/**
* 查询操作
*/
SELECT
}

View File

@ -0,0 +1,13 @@
package com.bipt.intelligentapplicationorchestrationservice.mapper;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import java.util.Map;
@Mapper
public interface DatasetMapper {
void updata(DatasetEntity datasetEntity);
}

View File

@ -0,0 +1,17 @@
package com.bipt.intelligentapplicationorchestrationservice.pojo;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @author hky
*/
@Data
public class DatasetDTO implements Serializable {
private Integer datasetId;
private String datasetName;
private Integer datasetType;
private Map<String,String> args;
}

View File

@ -0,0 +1,28 @@
package com.bipt.intelligentapplicationorchestrationservice.pojo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;
/**
* @author hky
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DatasetEntity implements Serializable {
private Integer datasetId;
private String datasetName;
private Integer datasetType;
private Integer datasetStatus;
private String dsPath;
private Map<String,String> args;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,40 @@
package com.bipt.intelligentapplicationorchestrationservice.pojo;
import lombok.Data;
import java.io.Serializable;
/**
* 后端统一返回结果
* @author hky
* @param <T>
*/
@Data
public class OptResult<T> implements Serializable {
private boolean isSuccess;
private String errorInfo;
private int statusCode;
private T data;
public static <T> OptResult<T> success() {
OptResult<T> result = new OptResult<>();
result.isSuccess = true;
return result;
}
public static <T> OptResult<T> success(T object) {
OptResult<T> result = new OptResult<>();
result.data = object;
result.isSuccess = true;
return result;
}
public static <T> OptResult<T> error(String errorInfo) {
OptResult result = new OptResult();
result.errorInfo = errorInfo;
result.isSuccess = false;
return result;
}
}

View File

@ -0,0 +1,11 @@
package com.bipt.intelligentapplicationorchestrationservice.service;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetDTO;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
import org.springframework.stereotype.Service;
public interface DatasetService {
void save(DatasetDTO datasetDTO);
void update(DatasetEntity datasetEntity);
}

View File

@ -0,0 +1,61 @@
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
import com.bipt.intelligentapplicationorchestrationservice.mapper.DatasetMapper;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetDTO;
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Map;
@Service
@Slf4j
public class DatasetServiceImpl implements DatasetService {
@Autowired
private DatasetMapper datasetMapper;
/**
* 新增数据集
* @param datasetDTO
*/
@Override
public void save(DatasetDTO datasetDTO) {
//判断数据集类型,如果是本地上传则保存,若用调用数据仓库进入下一步
if (datasetDTO.getDatasetType()==0){
//TODO 保存到分布式文件系统
}else {
Map<String,String> args = datasetDTO.getArgs();
Integer datasetType = datasetDTO.getDatasetType();
//TODO 根据筛选条件调用数据仓库中的数据
//TODO 调用数据仓库保存到分布式文件系统
}
}
/**
* 修改数据集
* @param datasetEntity
*/
@Override
@Transactional
public void update(DatasetEntity datasetEntity) {
if (datasetEntity.getDatasetType()==0){
//TODO 覆盖保存到分布式文件系统中
}else {
//TODO 覆盖数据文件
datasetEntity.setUpdateTime(LocalDateTime.now());
//maybe需要判断
datasetMapper.updata(datasetEntity);
}
}
}

View File

@ -1 +1,5 @@
spring.application.name=intelligent-application-orchestration-service
# ?????
spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
spring.datasource.username=system
spring.datasource.password=root

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.DatasetMapper">
<update id="updata">
update dataset
<set>
<if test="datasetName != null">
dataset_name=#{datasetName},
</if>
<if test="datasetType != null">
dataset_type=#{datasetType},
</if>
<if test="datasetStatus != null">
dataset_status=#{datasetStatus},
</if>
<if test="dsPath != null">
ds_path=#{dsPath},
</if>
<if test="args != null">
args=#{args},
</if>
<if test="create_time != null">
create_time=#{createTime},
</if>
<if test="update_time != null">
update_time=#{updateTime}
</if>
</set>
where dataset_id = #{datasetId}
</update>
</mapper>