Merge branch 'xiaohucoding'
# Conflicts: # pom.xml
This commit is contained in:
@ -10,4 +10,17 @@
|
||||
测试方法不知道怎么写
|
||||
|
||||
### 📅 明日计划
|
||||
写完删除代码,进行测试
|
||||
写完删除代码,进行测试
|
||||
|
||||
## 2025年5月15日
|
||||
### ✅ 今日完成
|
||||
完成删除数据集增加数据集,部分测试
|
||||
|
||||
### 🚧 进行中
|
||||
测试(或添加具体异常处理)
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
测试完毕,开下一个模块
|
15
pom.xml
15
pom.xml
@ -57,6 +57,12 @@
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<!--swagger相关依赖,生成接口文档-->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.3.0</version> <!-- 最新稳定版 -->
|
||||
</dependency>
|
||||
|
||||
<!--KingbaseES V8/V9 数据库 JDBC 驱动-->
|
||||
<dependency>
|
||||
@ -64,15 +70,6 @@
|
||||
<artifactId>kingbase8</artifactId>
|
||||
<version>9.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringDoc OpenAPI:自动生成 REST API 文档和 Swagger UI -->
|
||||
<!-- 访问路径:http://localhost:8080/swagger-ui.html -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.2.0</version> <!-- 最新稳定版 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -1,15 +1,20 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@MapperScan("com.bipt.intelligentapplicationorchestrationservice.mapper")//指定扫描Mapper接口的包
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@Slf4j
|
||||
public class IntelligentApplicationOrchestrationServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(IntelligentApplicationOrchestrationServiceApplication.class, args);
|
||||
log.info("server started");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
public class MessageConstant {
|
||||
public static final String UNKNOWN_ERROR = "未知错误";
|
||||
public static final String ALREADY_EXISTS = "数据集已存在";
|
||||
}
|
@ -2,7 +2,6 @@ package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -28,6 +27,11 @@ public class DatasetController {
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param dataSetPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public OptResult<PageResult> page(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||
log.info("数据集分页查询:{}", dataSetPageQueryDTO);
|
||||
@ -38,32 +42,28 @@ public class DatasetController {
|
||||
|
||||
/**
|
||||
* 修改数据集
|
||||
* @param datasetEntity
|
||||
* @param datasetDTO
|
||||
* @return
|
||||
*/
|
||||
@PutMapping
|
||||
public OptResult update(@RequestBody DatasetEntity datasetEntity){
|
||||
log.info("修改数据集",datasetEntity);
|
||||
datasetService.update(datasetEntity);
|
||||
public OptResult update(@RequestBody DatasetDTO datasetDTO){
|
||||
log.info("修改数据集",datasetDTO);
|
||||
datasetService.update(datasetDTO);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除数据集
|
||||
* @param datasetIds 数据集ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping
|
||||
public OptResult<String> deleteBatch(@RequestBody List<Integer> datasetIds) {
|
||||
public OptResult<String> deleteBatch(@RequestBody List<Long> datasetIds) {
|
||||
log.info("批量删除数据集,ID列表:{}", datasetIds);
|
||||
datasetService.deleteBatch(datasetIds);
|
||||
return OptResult.success("批量删除成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.handler;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器,处理项目中抛出的业务异常
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
/*
|
||||
* 捕获SQL异常
|
||||
* */
|
||||
@ExceptionHandler
|
||||
public OptResult exceptionHandler(SQLIntegrityConstraintViolationException ex){
|
||||
String message = ex.getMessage();
|
||||
if(message.contains("Duplicate entry")) {
|
||||
String[] split = message.split(" ");
|
||||
String username = split[2];
|
||||
String msg = username + MessageConstant.ALREADY_EXISTS;
|
||||
return OptResult.error(msg);
|
||||
}else {
|
||||
return OptResult.error(MessageConstant.UNKNOWN_ERROR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,6 @@ import com.github.pagehelper.Page;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DatasetMapper {
|
||||
@ -19,7 +18,7 @@ public interface DatasetMapper {
|
||||
Page<DatasetVO> pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO);
|
||||
|
||||
@Select("select * from dataset where dataset_id=#{datasetId}")
|
||||
DatasetEntity getById(Integer datasetId);
|
||||
@Delete("delete from dataset where dataset_id = #{datasetId}")
|
||||
void deleteBatch(List<Integer> datasetIds);
|
||||
DatasetEntity getById(Long datasetId);
|
||||
|
||||
void deleteBatch(@Param("datasetIds") List<Long> datasetIds);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
@ -9,9 +12,14 @@ import java.util.Map;
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetDTO implements Serializable {
|
||||
private Integer datasetId;
|
||||
private Long datasetId;
|
||||
private String datasetName;
|
||||
private Integer datasetType;
|
||||
private Map<String,String> args;
|
||||
private int datasetType;
|
||||
private String dsPath;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ import java.util.Map;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetEntity implements Serializable {
|
||||
private Integer datasetId;
|
||||
private Long datasetId;
|
||||
private String datasetName;
|
||||
private Integer datasetType;
|
||||
private Integer datasetStatus;
|
||||
private int datasetType;
|
||||
private int datasetStatus;
|
||||
private String dsPath;
|
||||
private Map<String,String> args;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
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;
|
||||
@ -10,9 +13,18 @@ import java.util.Map;
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetPageQueryDTO implements Serializable{
|
||||
private int page;
|
||||
private int pageSize;
|
||||
private Integer datasetType;
|
||||
private Integer datasetStatus;
|
||||
private String datasetName;
|
||||
private int datasetType;
|
||||
private int datasetStatus;
|
||||
private String dsPath;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
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;
|
||||
@ -7,12 +12,17 @@ import java.util.Map;
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetVO implements Serializable {
|
||||
private String datasetName;
|
||||
private Integer datasetType;
|
||||
private Integer datasetStatus;
|
||||
private String dsPath;
|
||||
private Map<String,String> args;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
@ -4,16 +4,17 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param <T>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageResult<T> {
|
||||
private Long total;
|
||||
private List<T> rows;
|
||||
@NoArgsConstructor
|
||||
public class PageResult implements Serializable {
|
||||
private long total;
|
||||
private List records;
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetPageQueryDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.PageResult;
|
||||
|
||||
@ -13,9 +12,9 @@ import java.util.List;
|
||||
public interface DatasetService {
|
||||
void save(DatasetDTO datasetDTO);
|
||||
|
||||
void update(DatasetEntity datasetEntity);
|
||||
void update(DatasetDTO datasetDTO);
|
||||
|
||||
PageResult pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO);
|
||||
|
||||
void deleteBatch(List<Integer> datasetIds);
|
||||
void deleteBatch(List<Long> datasetIds);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ -26,20 +26,22 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
* @param datasetDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(DatasetDTO datasetDTO) {
|
||||
//判断数据集类型,如果是本地上传则保存,若用调用数据仓库进入下一步
|
||||
if (datasetDTO.getDatasetType()==0){
|
||||
//TODO 保存到分布式文件系统
|
||||
|
||||
}else {
|
||||
Map<String,String> args = datasetDTO.getArgs();
|
||||
Integer datasetType = datasetDTO.getDatasetType();
|
||||
// Map<String,String> args = datasetDTO.getArgs();
|
||||
String args = datasetDTO.getArgs();
|
||||
int datasetType = datasetDTO.getDatasetType();
|
||||
//TODO 根据筛选条件调用数据仓库中的数据
|
||||
|
||||
//TODO 调用数据仓库保存到分布式文件系统
|
||||
}
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetEntity,datasetDTO);
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||
datasetEntity.setDatasetStatus(1);
|
||||
datasetEntity.setCreateTime(LocalDateTime.now());
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
@ -50,12 +52,14 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
/**
|
||||
* 修改数据集
|
||||
*
|
||||
* @param datasetEntity
|
||||
* @param datasetDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(DatasetEntity datasetEntity) {
|
||||
if (datasetEntity.getDatasetType()==0){
|
||||
public void update(DatasetDTO datasetDTO) {
|
||||
/*DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);*/
|
||||
if (datasetDTO.getDatasetType()==0){
|
||||
//TODO 覆盖保存到分布式文件系统中
|
||||
|
||||
}else {
|
||||
@ -63,9 +67,12 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
|
||||
|
||||
//TODO
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
datasetMapper.updata(datasetEntity);
|
||||
|
||||
}
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
datasetMapper.updata(datasetEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,9 +82,7 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
*/
|
||||
@Override
|
||||
public PageResult pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||
int pageNum = dataSetPageQueryDTO.getPage();
|
||||
int pageSize = dataSetPageQueryDTO.getPageSize();
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PageHelper.startPage(dataSetPageQueryDTO.getPage(), dataSetPageQueryDTO.getPageSize());
|
||||
Page<DatasetVO> page = datasetMapper.pageQuery(dataSetPageQueryDTO);
|
||||
return new PageResult(page.getTotal(), page.getResult());
|
||||
}
|
||||
@ -88,16 +93,16 @@ public class DatasetServiceImpl implements DatasetService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteBatch(List<Integer> datasetIds) {
|
||||
for (Integer datasetId : datasetIds) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,19 @@
|
||||
<if test="args != null">
|
||||
args=#{args},
|
||||
</if>
|
||||
<if test="create_time != null">
|
||||
create_time=#{createTime},
|
||||
</if>
|
||||
<if test="update_time != null">
|
||||
<if test="updateTime != null">
|
||||
update_time=#{updateTime}
|
||||
</if>
|
||||
</set>
|
||||
where dataset_id = #{datasetId}
|
||||
</update>
|
||||
<delete id="deleteBatch">
|
||||
DELETE FROM dataset
|
||||
WHERE dataset_id IN
|
||||
<foreach collection="datasetIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="pageQuery" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetVO">
|
||||
SELECT * FROM dataset
|
||||
<where>
|
||||
@ -49,8 +53,8 @@
|
||||
<if test="dsPath != null">
|
||||
and ds_path=#{dsPath}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time=#{createTime}
|
||||
<if test="args != null">
|
||||
and args=#{args}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time=#{createTime}
|
||||
|
Reference in New Issue
Block a user