Compare commits
4 Commits
cf38c648b2
...
9694fbc95c
Author | SHA1 | Date | |
---|---|---|---|
9694fbc95c | |||
6c838fbff1 | |||
a794b46f9b | |||
62cae458c8 |
16
doc/DesignDocument/模型服务表--hky.md
Normal file
16
doc/DesignDocument/模型服务表--hky.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# 数据库设计文档
|
||||||
|
|
||||||
|
## 服务发布
|
||||||
|
|
||||||
|
### 服务发布
|
||||||
|
|
||||||
|
#### 1.服务发布表(service_publish)
|
||||||
|
|
||||||
|
| 序号 | 数据表名 | 中文名称 |
|
||||||
|
| ---- | -------- | ------------------ |
|
||||||
|
| 1 | id | 发布表id(发布记录唯一标识) |
|
||||||
|
| 2 | model_id | 模型id |
|
||||||
|
| 3 | api_url | api路径 |
|
||||||
|
| 4 | create_time | 发布请求创建时间 |
|
||||||
|
|
||||||
|
####
|
@ -40,13 +40,26 @@
|
|||||||
|
|
||||||
## 2025年5月19日
|
## 2025年5月19日
|
||||||
### ✅ 今日完成
|
### ✅ 今日完成
|
||||||
完成了服务发布的表设计
|
模型发布的数据库设计
|
||||||
|
|
||||||
### 🚧 进行中
|
### 🚧 进行中
|
||||||
缓存设计
|
模型发布的逻辑开发
|
||||||
|
|
||||||
### ⚠️ 问题/障碍
|
### ⚠️ 问题/障碍
|
||||||
暂无
|
暂无
|
||||||
|
|
||||||
### 📅 明日计划
|
### 📅 明日计划
|
||||||
完成缓存设计,以及实体类设计
|
完成模型发布的逻辑开发
|
||||||
|
|
||||||
|
## 2025年5月20日
|
||||||
|
### ✅ 今日完成
|
||||||
|
服务发布逻辑开发(无GPU版)
|
||||||
|
|
||||||
|
### 🚧 进行中
|
||||||
|
redis设计
|
||||||
|
|
||||||
|
### ⚠️ 问题/障碍
|
||||||
|
暂无
|
||||||
|
|
||||||
|
### 📅 明日计划
|
||||||
|
完成redis设计,做完服务发布的逻辑开发
|
10
pom.xml
10
pom.xml
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.4.5</version>
|
<version>3.2.5</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.bipt</groupId>
|
<groupId>com.bipt</groupId>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<url/>
|
<url/>
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>24</java.version>
|
<java.version>21</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -39,6 +39,10 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class RedisConfiguration {
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
|
||||||
|
log.info("开始创建redis模板对象...");
|
||||||
|
RedisTemplate redisTemplate = new RedisTemplate();
|
||||||
|
//设置redis的连接工厂对象
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
//设置redis key的序列化器
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
|
||||||
|
return redisTemplate;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,5 +2,5 @@ package com.bipt.intelligentapplicationorchestrationservice.constant;
|
|||||||
|
|
||||||
public class MessageConstant {
|
public class MessageConstant {
|
||||||
public static final String UNKNOWN_ERROR = "未知错误";
|
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.pojo.*;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@Tag(name ="数据集相关接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dataset")
|
@RequestMapping("/dataset")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -20,6 +22,7 @@ public class DatasetController {
|
|||||||
* @param datasetDTO
|
* @param datasetDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Operation(summary ="新增数据集")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public OptResult save(@RequestBody DatasetDTO datasetDTO) {
|
public OptResult save(@RequestBody DatasetDTO datasetDTO) {
|
||||||
log.info("新增数据集:{}", datasetDTO);
|
log.info("新增数据集:{}", datasetDTO);
|
||||||
@ -32,6 +35,7 @@ public class DatasetController {
|
|||||||
* @param dataSetPageQueryDTO
|
* @param dataSetPageQueryDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Operation(summary ="分页查询")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public OptResult<PageResult> page(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
public OptResult<PageResult> page(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||||
log.info("数据集分页查询:{}", dataSetPageQueryDTO);
|
log.info("数据集分页查询:{}", dataSetPageQueryDTO);
|
||||||
@ -45,6 +49,7 @@ public class DatasetController {
|
|||||||
* @param datasetDTO
|
* @param datasetDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Operation(summary ="修改数据集")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public OptResult update(@RequestBody DatasetDTO datasetDTO){
|
public OptResult update(@RequestBody DatasetDTO datasetDTO){
|
||||||
log.info("修改数据集",datasetDTO);
|
log.info("修改数据集",datasetDTO);
|
||||||
@ -59,6 +64,7 @@ public class DatasetController {
|
|||||||
* @param datasetIds 数据集ID列表
|
* @param datasetIds 数据集ID列表
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
|
@Operation(summary ="删除数据集")
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public OptResult<String> deleteBatch(@RequestBody List<Long> datasetIds) {
|
public OptResult<String> deleteBatch(@RequestBody List<Long> datasetIds) {
|
||||||
log.info("批量删除数据集,ID列表:{}", datasetIds);
|
log.info("批量删除数据集,ID列表:{}", datasetIds);
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||||
|
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Tag(name ="服务发布相关接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/publish")
|
||||||
|
@Slf4j
|
||||||
|
public class publishController {
|
||||||
|
@Autowired
|
||||||
|
private PublishService publishService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增请求发布
|
||||||
|
* @param servicePublishDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary ="新增发布请求")
|
||||||
|
public OptResult<ServicePublishVO> save(@RequestBody ServicePublishDTO servicePublishDTO){
|
||||||
|
log.info("模型发布请求:{}", servicePublishDTO);
|
||||||
|
publishService.save(servicePublishDTO);
|
||||||
|
ServicePublishVO servicePublishVO = publishService.getByModelId(servicePublishDTO);
|
||||||
|
return OptResult.success(servicePublishVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PublishMapper {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void insert(ServicePublishDTO servicePublishDTO);
|
||||||
|
|
||||||
|
Long getByApiUrl(String apiUrl);
|
||||||
|
@Select("select * from model_version where model_id=#{modelId} and status = 1")
|
||||||
|
ModelVersion getById(Long modelId);
|
||||||
|
|
||||||
|
ServicePublishVO getByModelId(Long modelId);
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hky
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ServicePublish implements Serializable {
|
||||||
|
private Long id;
|
||||||
|
private Long modelId;
|
||||||
|
private String apiUrl;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
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;
|
||||||
|
/**
|
||||||
|
* @author hky
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ServicePublishDTO implements Serializable {
|
||||||
|
private Long id;
|
||||||
|
private Long modelId;
|
||||||
|
private String apiUrl;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hky
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ServicePublishVO implements Serializable {
|
||||||
|
private Long modelId;
|
||||||
|
private String apiUrl;
|
||||||
|
private String version;
|
||||||
|
private Integer datasetId;
|
||||||
|
private String modelConfig;
|
||||||
|
private String modelPath;
|
||||||
|
private Integer status;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
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.mapper.DatasetMapper;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||||
@ -15,6 +17,8 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType.FROM_DATABASE;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DatasetServiceImpl implements DatasetService {
|
public class DatasetServiceImpl implements DatasetService {
|
||||||
@ -29,20 +33,26 @@ public class DatasetServiceImpl implements DatasetService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void save(DatasetDTO datasetDTO) {
|
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 {
|
//TODO 调用数据仓库保存到分布式文件系统
|
||||||
// Map<String,String> args = datasetDTO.getArgs();
|
break;
|
||||||
String args = datasetDTO.getArgs();
|
default:
|
||||||
int datasetType = datasetDTO.getDatasetType();
|
throw new IllegalArgumentException("不支持的数据集类型: " + datasetType);
|
||||||
//TODO 根据筛选条件调用数据仓库中的数据
|
|
||||||
|
|
||||||
//TODO 调用数据仓库保存到分布式文件系统
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DatasetEntity datasetEntity = new DatasetEntity();
|
DatasetEntity datasetEntity = new DatasetEntity();
|
||||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||||
datasetEntity.setDatasetStatus(1);
|
datasetEntity.setDatasetStatus(StatusConstant.ENABLE);
|
||||||
datasetEntity.setCreateTime(LocalDateTime.now());
|
datasetEntity.setCreateTime(LocalDateTime.now());
|
||||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||||
datasetMapper.insert(datasetEntity);
|
datasetMapper.insert(datasetEntity);
|
||||||
@ -59,15 +69,18 @@ public class DatasetServiceImpl implements DatasetService {
|
|||||||
public void update(DatasetDTO datasetDTO) {
|
public void update(DatasetDTO datasetDTO) {
|
||||||
/*DatasetEntity datasetEntity = new DatasetEntity();
|
/*DatasetEntity datasetEntity = new DatasetEntity();
|
||||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);*/
|
BeanUtils.copyProperties(datasetDTO,datasetEntity);*/
|
||||||
if (datasetDTO.getDatasetType()==0){
|
DatasetType datasetType = DatasetType.fromCode(datasetDTO.getDatasetType());
|
||||||
//TODO 覆盖保存到分布式文件系统中
|
// 根据类型处理数据
|
||||||
|
switch (datasetType) {
|
||||||
}else {
|
case UPLOAD:
|
||||||
//TODO 覆盖数据文件
|
//TODO 覆盖保存到分布式文件系统中
|
||||||
|
break;
|
||||||
|
case FROM_DATABASE:
|
||||||
//TODO
|
//TODO 覆盖数据文件
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("不支持的数据集类型: " + datasetType);
|
||||||
}
|
}
|
||||||
DatasetEntity datasetEntity = new DatasetEntity();
|
DatasetEntity datasetEntity = new DatasetEntity();
|
||||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||||
@ -94,14 +107,7 @@ public class DatasetServiceImpl implements DatasetService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteBatch(List<Long> 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 在分布式文件系统中删除
|
//TODO 在分布式文件系统中删除
|
||||||
datasetMapper.deleteBatch(datasetIds);
|
datasetMapper.deleteBatch(datasetIds);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hky
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class PublishServiceImpl implements PublishService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PublishMapper publishMapper;
|
||||||
|
/**
|
||||||
|
* 新增服务请求
|
||||||
|
* @param servicePublishDTO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void save(ServicePublishDTO servicePublishDTO) {
|
||||||
|
String apiUrl = servicePublishDTO.getApiUrl();
|
||||||
|
Long id = publishMapper.getByApiUrl(apiUrl);
|
||||||
|
if (id != null){
|
||||||
|
throw new IllegalArgumentException("请求已存在: " + apiUrl);
|
||||||
|
}
|
||||||
|
Long modelId = servicePublishDTO.getModelId();
|
||||||
|
ModelVersion modelVersion = publishMapper.getById(modelId);
|
||||||
|
String modelConfig = modelVersion.getModelConfig();
|
||||||
|
//todo 调用GPU分配
|
||||||
|
|
||||||
|
|
||||||
|
publishMapper.insert(servicePublishDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO) {
|
||||||
|
Long modelId = servicePublishDTO.getModelId();
|
||||||
|
return publishMapper.getByModelId(modelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||||
|
|
||||||
|
public interface PublishService {
|
||||||
|
void save(ServicePublishDTO servicePublishDTO);
|
||||||
|
|
||||||
|
ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO);
|
||||||
|
}
|
@ -15,4 +15,15 @@ mybatis.mapper-locations=classpath:mapper/*.xml
|
|||||||
# 配置实体类别名所在包
|
# 配置实体类别名所在包
|
||||||
mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice.pojo
|
mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice.pojo
|
||||||
# 开启驼峰命名转换
|
# 开启驼峰命名转换
|
||||||
mybatis.configuration.map-underscore-to-camel-case=true
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
|
|
||||||
|
# Redis服务器地址
|
||||||
|
spring.data.redis.host=localhost
|
||||||
|
# Redis服务器端口
|
||||||
|
spring.data.redis.port=6379
|
||||||
|
# Redis密码(如果有)
|
||||||
|
spring.data.redis.password=123456
|
||||||
|
# Redis数据库索引(默认为0)
|
||||||
|
spring.data.redis.database=2
|
||||||
|
# 连接超时时间(毫秒)
|
||||||
|
spring.data.redis.timeout=3000
|
||||||
|
20
src/main/resources/mapper/PublishMapper.xml
Normal file
20
src/main/resources/mapper/PublishMapper.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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.PublishMapper">
|
||||||
|
<insert id="insert">
|
||||||
|
INSERT INTO service_publish
|
||||||
|
(id,model_id,api_url,create_time)
|
||||||
|
values (#{id}, #{modelId}, #{apiUrl}, #{createTime})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="getByApiUrl" resultType="java.lang.Long">
|
||||||
|
SELECT id FROM service_publish WHERE api_url = #{apiUrl};
|
||||||
|
</select>
|
||||||
|
<select id="getByModelId"
|
||||||
|
resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO">
|
||||||
|
select
|
||||||
|
sp.api_url,
|
||||||
|
mv.*
|
||||||
|
from model_version mv join service_publish sp on mv.model_id = sp.model_id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user