Merge pull request '数据集 模型接口' (#3) from Xidaray into master

This commit is contained in:
fanshuai 2024-01-02 14:19:49 +08:00
commit 5f32b875d0
30 changed files with 458 additions and 149 deletions

View File

@ -1,5 +1,9 @@
package com.ruoyi.platform.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.io.Serializable;
import java.util.Date;
@ -9,6 +13,7 @@ import java.util.Date;
* @author makejava
* @since 2023-12-14 11:17:00
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class Component implements Serializable {
private static final long serialVersionUID = -56592844039218605L;
/**
@ -30,6 +35,7 @@ public class Component implements Serializable {
/**
* 镜像
*/
@JsonProperty("image")
private String images;
/**
* 工作目录
@ -42,6 +48,7 @@ public class Component implements Serializable {
/**
* 环境变量
*/
@JsonProperty("env_variables")
private String envVirables;
/**
* 资源规格
@ -70,6 +77,8 @@ public class Component implements Serializable {
/**
* 创建者
*/
//@JsonProperty("creater")
private String createBy;
/**
* 创建时间
@ -78,6 +87,7 @@ public class Component implements Serializable {
/**
* 更新者
*/
//@JsonProperty("modify_by")
private String updateBy;
/**
* 更新时间

View File

@ -1,5 +1,8 @@
package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.util.Date;
import java.io.Serializable;
@ -9,6 +12,7 @@ import java.io.Serializable;
* @author Xidaray
* @since 2023-11-29 14:23:01
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ComputingResource implements Serializable {
private static final long serialVersionUID = -42500298368776666L;
/**

View File

@ -1,5 +1,8 @@
package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.util.Date;
import java.io.Serializable;
@ -9,6 +12,7 @@ import java.io.Serializable;
* @author Xidaray
* @since 2023-11-28 11:51:22
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class Dataset implements Serializable {
private static final long serialVersionUID = 918442714458737041L;

View File

@ -29,6 +29,8 @@ public class ExperimentIns implements Serializable {
* 实例运行状态
*/
private String status;
private String nodesStatus;
/**
* 创建者
*/
@ -50,6 +52,9 @@ public class ExperimentIns implements Serializable {
*/
private Integer state;
public ExperimentIns() {
}
public Integer getId() {
return id;
@ -91,6 +96,15 @@ public class ExperimentIns implements Serializable {
this.status = status;
}
public String getNodesStatus() {
return nodesStatus;
}
public void setNodesStatus(String nodesStatus) {
this.nodesStatus = nodesStatus;
}
public String getCreateBy() {
return createBy;
}

View File

@ -3,8 +3,7 @@ package com.ruoyi.platform.mapper;
import com.ruoyi.platform.domain.Component;
import com.ruoyi.platform.vo.ComponentVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
@ -78,7 +77,7 @@ public interface ComponentDao {
* @param component 实例对象
* @return 影响行数
*/
int update(@Param("component")Component component);
int update(@Param("component") Component component);
/**
* 通过主键删除数据
@ -86,7 +85,10 @@ public interface ComponentDao {
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
int deleteById(@Param("id") Integer id);
// 检查相同category_id下的component_name是否存在
Integer countByNameAndCategoryId(@Param("componentName") String componentName, @Param("categoryId") Integer categoryId);
}

View File

@ -71,7 +71,7 @@ public interface DatasetDao {
* @param dataset 实例对象
* @return 影响行数
*/
int update(Dataset dataset);
int update(@Param("dataset") Dataset dataset);
/**
* 通过主键删除数据

View File

@ -45,7 +45,7 @@ public interface ModelsDao {
* @param models 实例对象
* @return 影响行数
*/
int insert(Models models);
int insert(@Param("models") Models models);
/**
* 批量新增数据MyBatis原生foreach方法
@ -70,7 +70,7 @@ public interface ModelsDao {
* @param models 实例对象
* @return 影响行数
*/
int update(Models models);
int update(@Param("models") Models models);
/**
* 通过主键删除数据

View File

@ -44,7 +44,7 @@ public interface ComponentService {
* @param component 实例对象
* @return 实例对象
*/
Component update(Component component);
Component update(ComponentVo component);
/**
* 通过主键删除数据

View File

@ -8,6 +8,7 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
/**
* (Dataset)表服务接口
@ -46,6 +47,8 @@ public interface DatasetService {
*/
Dataset insert(Dataset dataset);
/**
* 修改数据
*
@ -65,4 +68,6 @@ public interface DatasetService {
String removeById(Integer id);
ResponseEntity<InputStreamResource> downloadDataset(Integer id);
String uploadDataset(MultipartFile file, Integer id) throws Exception;
}

View File

@ -71,7 +71,7 @@ public interface ExperimentInsService {
List<ExperimentIns> queryByExperimentId(Integer id);
String queryStatusFromArgo(String namespace, String name);
String queryStatusFromArgo(String namespace, String name, Integer id);
boolean terminateExperimentIns(Integer id);

View File

@ -7,6 +7,7 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
/**
* (Models)表服务接口
@ -61,4 +62,6 @@ public interface ModelsService {
String removeById(Integer id);
ResponseEntity<InputStreamResource> downloadModels(Integer id);
String uploadModels(MultipartFile file, Integer id) throws Exception;
}

View File

@ -3,7 +3,6 @@ package com.ruoyi.platform.service.impl;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.platform.domain.Component;
import com.ruoyi.platform.domain.ComputingResource;
import com.ruoyi.platform.service.ComponentService;
import com.ruoyi.platform.mapper.ComponentDao;
import com.ruoyi.platform.utils.ConvertUtil;
@ -39,6 +38,11 @@ public class ComponentServiceImpl implements ComponentService {
*/
@Override
public Component queryById(Integer id) {
Component component = this.componentDao.queryById(id);
if (component == null){
throw new RuntimeException("组件不存在");
}
return this.componentDao.queryById(id);
}
@ -74,6 +78,15 @@ public class ComponentServiceImpl implements ComponentService {
component.setUpdateBy(loginUser.getUser().getUserName());
component.setUpdateTime(new Date());
component.setCreateTime(new Date());
component.setState(1);
// 检查相同category_id下的component_name是否已存在
Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId());
if(existingCount != null && existingCount > 0) {
throw new RuntimeException("该类别下已有同名组件。");
}
this.componentDao.insert(component);
return component;
}
@ -81,11 +94,27 @@ public class ComponentServiceImpl implements ComponentService {
/**
* 修改数据
*
* @param component 实例对象
* @param componentVo 实例对象
* @return 实例对象
*/
@Override
public Component update(Component component) {
public Component update(ComponentVo componentVo) {
Component component = this.queryById(componentVo.getId());
//只能更新当前存在的组件
if (component == null){
throw new RuntimeException("组件不存在,无法更新。");
}
//将object转成string类型
component = ConvertUtil.entityToVo(componentVo,Component.class);
component.setEnvVirables(componentVo.getEnvVirables().toString());
component.setInParameters(componentVo.getInParameters().toString());
component.setOutParameters(componentVo.getOutParameters().toString());
LoginUser loginUser = SecurityUtils.getLoginUser();
component.setUpdateBy(loginUser.getUser().getUserName());
component.setUpdateTime(new Date());
this.componentDao.update(component);
return this.queryById(component.getId());
}
@ -104,16 +133,18 @@ public class ComponentServiceImpl implements ComponentService {
@Override
public String removeById(Integer id) {
Component component = this.componentDao.queryById(id);
if (component == null){
return "计算资源不存在";
//先进行判断 组件是否存在
if (component == null ){
return "组件不存在";
}
//判断权限只有admin和创建者本身可以删除该数据集
//判断权限只有admin和创建者本身可以删除该组件
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUser().getUserName();
String createdBy = component.getCreateBy();
if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){
return "无权限删除该计算资源";
return "无权限删除该组件";
}
component.setState(0);

View File

@ -64,6 +64,7 @@ public class ComputingResourceServiceImpl implements ComputingResourceService {
computingResource.setUpdateBy(loginUser.getUser().getUserName());
computingResource.setUpdateTime(new Date());
computingResource.setCreateTime(new Date());
computingResource.setState(1);
this.computingResourceDao.insert(computingResource);
return computingResource;
}

View File

@ -6,7 +6,10 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.platform.domain.Dataset;
import com.ruoyi.platform.service.DatasetService;
import com.ruoyi.platform.mapper.DatasetDao;
import com.ruoyi.platform.utils.MinioUtil;
import io.minio.MinioClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -16,14 +19,13 @@ import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
@ -37,6 +39,28 @@ public class DatasetServiceImpl implements DatasetService {
@Resource
private DatasetDao datasetDao;
private DatasetService datasetService;
private MinioClient minioClient;
@Value("${minio.endpoint}")
private String minioEndpoint;
@Value("${minio.accessKey}")
private String minioAccessKey;
@Value("${minio.secretKey}")
private String minioSecretKey;
// 固定存储桶名
private final String bucketName = "platform-data";
private final MinioUtil minioUtil;
public DatasetServiceImpl(MinioUtil minioUtil) {
this.minioUtil = minioUtil;
}
/**
* 通过ID查询单条数据
@ -76,6 +100,7 @@ public class DatasetServiceImpl implements DatasetService {
dataset.setUpdateBy(loginUser.getUser().getUserName());
dataset.setUpdateTime(new Date());
dataset.setCreateTime(new Date());
dataset.setState(1);
this.datasetDao.insert(dataset);
return dataset;
}
@ -88,6 +113,13 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
public Dataset update(Dataset dataset) {
int currentState = dataset.getState();
if (currentState == 0){
throw new RuntimeException("数据集已被删除,无法更新。");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
dataset.setUpdateBy(loginUser.getUser().getUserName());
dataset.setUpdateTime(new Date());
this.datasetDao.update(dataset);
return this.queryById(dataset.getId());
}
@ -107,7 +139,7 @@ public class DatasetServiceImpl implements DatasetService {
public String removeById(Integer id) {
Dataset dataset = this.datasetDao.queryById(id);
if (dataset == null){
return "实验不存在";
return "数据集不存在";
}
//判断权限只有admin和创建者本身可以删除该数据集
@ -116,45 +148,90 @@ public class DatasetServiceImpl implements DatasetService {
String createdBy = dataset.getCreateBy();
if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){
return "无权限删除该数据集";
}
dataset.setState(0);
return this.datasetDao.update(dataset)>0?"删除数据集成功":"删除数据集失败";
}
/**
* 下载数据集
*
* @param id 主键
* @return 文件内容
*/
@Override
public ResponseEntity<InputStreamResource> downloadDataset(Integer id) {
Dataset dataset = this.datasetDao.queryById(id);
if (dataset == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
String url = dataset.getUrl();
if(url == null || url.isEmpty() ){
// 从数据库中获取存储路径即MinIO中的对象名称
String objectName = dataset.getUrl();
if(objectName == null || objectName.isEmpty() ){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
try {
URL downloadurl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) downloadurl.openConnection();
connection.setRequestMethod("GET");
// 使用ByteArrayOutputStream来捕获下载的数据
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
minioUtil.downloadObject(bucketName,objectName,outputStream);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
InputStreamResource resource = new InputStreamResource(inputStream);
// 检查HTTP响应码
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
InputStreamResource resource = new InputStreamResource(connection.getInputStream());
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + extractFileName(url) + "\"")
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + extractFileName(objectName) + "\"")
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(resource);
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
/**
* 上传数据集
*
* @param file 文件
* @param id 主键
* @return 是否成功
*/
@Override
public String uploadDataset(MultipartFile file, Integer id) throws Exception {
if(file.isEmpty()){
throw new Exception("文件为空,无法上传");
}
Dataset dataset = this.datasetDao.queryById(id);
if (dataset == null) {
throw new Exception("未找到数据集记录");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
//拼接objectName
String username = loginUser.getUser().getUserName();
String version = dataset.getVersion();
Date createTime = dataset.getCreateTime();
//格式化日期为时间戳字符串
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
String timestamp = sdf.format(createTime);
String objectName = "datasets/" + username + "/" + dataset.getName() + "-" + timestamp + "/" + version + "/" + file.getOriginalFilename();
// 上传文件到MinIO
try (InputStream inputStream = file.getInputStream()) {
minioUtil.uploadObject(bucketName, objectName, inputStream);
// 更新数据库url记录
dataset.setUrl(objectName);
update(dataset);
return "数据集成功上传到: " + objectName;
} catch (Exception e) {
throw new Exception("上传到MinIO失败: " + e.getMessage(), e);
}
}
private String extractFileName(String urlStr) {
return urlStr.substring(urlStr.lastIndexOf('/') + 1);
}

View File

@ -57,15 +57,26 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
@Override
public ExperimentIns queryById(Integer id) {
ExperimentIns experimentIns = this.experimentInsDao.queryById(id);
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
experimentIns.setStatus(status);
this.update(experimentIns);
String currentStatus = experimentIns.getStatus();
// 检查是否需要调用接口查询状态当原本状态为null或running或Pending时调用argo接口
if (StringUtils.isEmpty(currentStatus) || StringUtils.equals(currentStatus, "Running") || StringUtils.equals(currentStatus,"Pending")) {
String newStatus = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(), id );
// 如果新状态不是null并且与旧状态不同则更新状态
if(!StringUtils.isEmpty(newStatus) && !StringUtils.equals(newStatus, currentStatus)){
experimentIns.setStatus(newStatus);
this.update(experimentIns);
}
}
return experimentIns;
}
/**
*
*
* 根据实验ID查找所有具有相同ID的实例并将它们添加到实验列表中
*
* @param experimentId 实验ID
@ -76,7 +87,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
List<ExperimentIns> experimentInsList = experimentInsDao.getByExperimentId(experimentId);
for (ExperimentIns experimentIns: experimentInsList) {
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
Integer experimentInsId = experimentIns.getId();
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(),experimentInsId);
experimentIns.setStatus(status);
this.update(experimentIns);
}
@ -97,8 +109,10 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
long total = this.experimentInsDao.count(experimentIns);
List<ExperimentIns> experimentInsList = this.experimentInsDao.queryAllByLimit(experimentIns, pageRequest);
for (ExperimentIns ins: experimentInsList) {
//如果实验实例不为空或者
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
String status = this.queryStatusFromArgo(ins.getArgoInsNs(), ins.getArgoInsName());
Integer experimentInsId = experimentIns.getId();
String status = this.queryStatusFromArgo(ins.getArgoInsNs(), ins.getArgoInsName(), experimentInsId );
ins.setStatus(status);
this.update(experimentIns);
}
@ -158,7 +172,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
}
if (StringUtils.isEmpty(experimentIns.getStatus())){
experimentIns.setStatus(queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName()));
experimentIns.setStatus(queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(), id));
}
if (StringUtils.equals(experimentIns.getStatus(),"Running")){
return "实验实例正在运行,不可删除";
@ -189,7 +203,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
}
@Override
public String queryStatusFromArgo(String namespace, String name) {
public String queryStatusFromArgo(String namespace, String name, Integer id) {
ExperimentIns experimentIns = this.experimentInsDao.queryById(id);
// 创建请求数据map
Map<String,Object> requestData = new HashMap<>();
requestData.put("namespace", namespace);
@ -218,11 +233,24 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
if (status == null || status.isEmpty()) {
throw new RuntimeException("工作流状态为空。");
}
// 解析nodes字段,提取节点状态并转换为JSON字符串
Map<String, Object> nodes = (Map<String, Object>) status.get("nodes");
if (nodes == null || nodes.isEmpty()) {
throw new RuntimeException("工作流的节点数据为空。");
}
String nodeStatusJson = JsonUtils.mapToJson(nodes);
experimentIns.setNodesStatus(nodeStatusJson);
this.experimentInsDao.update(experimentIns);
return (String) status.get("phase");
} catch (Exception e) {
throw new RuntimeException("查询状态失败: " + e.getMessage(), e);
}
}
@ -245,7 +273,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
String namespace = experimentIns.getArgoInsNs();
// 获取当前状态如果为空则从Argo查询
if (StringUtils.isEmpty(currentStatus)) {
currentStatus = queryStatusFromArgo(namespace, name);
currentStatus = queryStatusFromArgo(namespace, name, id );
}
// 只有状态是"Running"时才能终止实例

View File

@ -6,7 +6,10 @@ import com.ruoyi.platform.domain.Dataset;
import com.ruoyi.platform.domain.Models;
import com.ruoyi.platform.service.ModelsService;
import com.ruoyi.platform.mapper.ModelsDao;
import com.ruoyi.platform.utils.MinioUtil;
import io.minio.MinioClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -16,11 +19,13 @@ import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
@ -34,6 +39,26 @@ public class ModelsServiceImpl implements ModelsService {
@Resource
private ModelsDao modelsDao;
private MinioClient minioClient;
@Value("${minio.endpoint}")
private String minioEndpoint;
@Value("${minio.accessKey}")
private String minioAccessKey;
@Value("${minio.secretKey}")
private String minioSecretKey;
// 固定存储桶名
private final String bucketName = "platform-data";
private final MinioUtil minioUtil;
public ModelsServiceImpl(MinioUtil minioUtil) {
this.minioUtil = minioUtil;
}
/**
* 通过ID查询单条数据
*
@ -71,7 +96,7 @@ public class ModelsServiceImpl implements ModelsService {
models.setUpdateBy(loginUser.getUser().getUserName());
models.setUpdateTime(new Date());
models.setCreateTime(new Date());
models.setState(1);
this.modelsDao.insert(models);
return models;
}
@ -84,6 +109,14 @@ public class ModelsServiceImpl implements ModelsService {
*/
@Override
public Models update(Models models) {
int currentState = models.getState();
if(currentState == 0){
throw new RuntimeException("模型已被删除,无法更新。");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
models.setUpdateBy(loginUser.getUser().getUserName());
models.setUpdateTime(new Date());
this.modelsDao.update(models);
return this.queryById(models.getId());
}
@ -103,7 +136,7 @@ public class ModelsServiceImpl implements ModelsService {
public String removeById(Integer id) {
Models models = this.modelsDao.queryById(id);
if (models == null){
return "实验不存在";
return "模型不存在";
}
//判断权限只有admin和创建者本身可以删除该数据集
@ -118,40 +151,75 @@ public class ModelsServiceImpl implements ModelsService {
return this.modelsDao.update(models)>0?"删除成功":"删除失败";
}
/**
* 下载模型
*
* @param id 主键
* @return 文件内容
*/
@Override
public ResponseEntity<InputStreamResource> downloadModels(Integer id) {
Models models = this.modelsDao.queryById(id);
if (models == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
//获取模型下载url
String url = models.getUrl();
if(url == null || url.isEmpty() ){
// 从数据库中获取存储路径即MinIO中的对象名称
String objectName = models.getUrl();
if(objectName == null || objectName.isEmpty() ){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
try {
URL downloadurl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) downloadurl.openConnection();
connection.setRequestMethod("GET");
// 检查HTTP响应码
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
InputStreamResource resource = new InputStreamResource(connection.getInputStream());
// 使用ByteArrayOutputStream来捕获下载的数据
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
minioUtil.downloadObject(bucketName,objectName,outputStream);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
InputStreamResource resource = new InputStreamResource(inputStream);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + extractFileName(url) + "\"")
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + extractFileName(objectName) + "\"")
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(resource);
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
@Override
public String uploadModels(MultipartFile file, Integer id) throws Exception{
if(file.isEmpty()){
throw new Exception("文件为空,无法上传");
}
Models models = this.modelsDao.queryById(id);
if (models == null) {
throw new Exception("未找到模型记录");
}
//得到用户名
LoginUser loginUser = SecurityUtils.getLoginUser();
String version = models.getVersion();
String username = loginUser.getUser().getUserName();
Date createTime = models.getCreateTime();
//格式化日期为时间戳字符串
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
String timestamp = sdf.format(createTime);
//拼接objectName
String objectName = "models/" + username + "/" + models.getName() + "-" + timestamp + "/" + version + "/" + file.getOriginalFilename();
// 上传文件到MinIO
try (InputStream inputStream = file.getInputStream()) {
minioUtil.uploadObject(bucketName, objectName, inputStream);
// 更新数据库url
models.setUrl(objectName);
update(models);
return "模型成功上传到: " + objectName;
} catch (Exception e) {
throw new Exception("上传到MinIO失败: " + e.getMessage(), e);
}
}
private String extractFileName(String urlStr) {
return urlStr.substring(urlStr.lastIndexOf('/') + 1);
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.platform.utils;
import io.minio.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

View File

@ -1,8 +1,13 @@
package com.ruoyi.platform.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.io.Serializable;
import java.util.Date;
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ComponentVo implements Serializable {
private static final long serialVersionUID = -56592844039218605L;
/**
@ -24,6 +29,7 @@ public class ComponentVo implements Serializable {
/**
* 镜像
*/
@JsonProperty("image")
private String images;
/**
* 工作目录
@ -36,6 +42,7 @@ public class ComponentVo implements Serializable {
/**
* 环境变量
*/
@JsonProperty("env_variables")
private Object envVirables;
/**
* 资源规格

View File

@ -28,7 +28,7 @@
select
id,category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,create_by,create_time,update_by,update_time,state
from component
where id = #{id}
where id = #{id} and state = 1
</select>
<!--查询指定行数据-->
@ -159,6 +159,15 @@
</where>
</select>
<select id="countByNameAndCategoryId" resultType="java.lang.Integer">
select count(1)
from component
where category_id = #{categoryId}
and component_name = #{componentName}
and state = 1
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into component(category_id,component_name,component_label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,create_by,create_time,update_by,update_time,state)
@ -188,63 +197,64 @@ category_id = values(category_id)component_name = values(component_name)componen
update component
<set>
<if test="component.id != null">
and id = #{component.id}
id = #{component.id},
</if>
<if test="component.categoryId != null">
and category_id = #{component.categoryId}
category_id = #{component.categoryId},
</if>
<if test="component.componentName != null and component.componentName != ''">
and component_name = #{component.componentName}
component_name = #{component.componentName},
</if>
<if test="component.componentLabel != null and component.componentLabel != ''">
and component_label = #{component.componentLabel}
component_label = #{component.componentLabel},
</if>
<if test="component.images != null and component.images != ''">
and images = #{component.images}
images = #{component.images},
</if>
<if test="component.workingDirectory != null and component.workingDirectory != ''">
and working_directory = #{component.workingDirectory}
working_directory = #{component.workingDirectory},
</if>
<if test="component.command != null and component.command != ''">
and command = #{component.command}
command = #{component.command},
</if>
<if test="component.envVirables != null and component.envVirables != ''">
and env_virables = #{component.envVirables}
env_virables = #{component.envVirables},
</if>
<if test="component.resourcesStandard != null and component.resourcesStandard != ''">
and resources_standard = #{component.resourcesStandard}
resources_standard = #{component.resourcesStandard},
</if>
<if test="component.controlStrategy != null and component.controlStrategy != ''">
and control_strategy = #{component.controlStrategy}
control_strategy = #{component.controlStrategy},
</if>
<if test="component.mountPath != null and component.mountPath != ''">
and mount_path = #{component.mountPath}
mount_path = #{component.mountPath},
</if>
<if test="component.inParameters != null and component.inParameters != ''">
and in_parameters = #{component.inParameters}
in_parameters = #{component.inParameters},
</if>
<if test="component.outParameters != null and component.outParameters != ''">
and out_parameters = #{component.outParameters}
out_parameters = #{component.outParameters},
</if>
<if test="component.createBy != null and component.createBy != ''">
and create_by = #{component.createBy}
create_by = #{component.createBy},
</if>
<if test="component.createTime != null">
and create_time = #{component.createTime}
create_time = #{component.createTime},
</if>
<if test="component.updateBy != null and component.updateBy != ''">
and update_by = #{component.updateBy}
update_by = #{component.updateBy},
</if>
<if test="component.updateTime != null">
and update_time = #{component.updateTime}
update_time = #{component.updateTime},
</if>
<if test="component.state != null">
and state = #{component.state}
state = #{component.state}
</if>
</set>
where id = #{id}
where id = #{component.id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from component where id = #{id}

View File

@ -19,7 +19,7 @@
select
id,computing_resource,standard,description,create_by,create_time,update_by,update_time,state
from computing_resource
where id = #{id}
where id = #{id} and state = 1
</select>
<!--查询指定行数据-->
@ -153,7 +153,7 @@ computing_resource = values(computing_resource)standard = values(standard)descri
</if>
</set>
where id = #{id}
where id = #{computingResource.id}
</update>
<!--通过主键删除-->

View File

@ -21,7 +21,7 @@
select
id,name,version,description,url,data_type,create_by,create_time,update_by,update_time,state
from dataset
where id = #{id}
where id = #{id} and state = 1
</select>
<!--查询指定行数据-->
@ -112,8 +112,8 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into dataset(nameversiondescriptionurldata_typecreate_bycreate_timeupdate_byupdate_timestate)
values (#{name}#{version}#{description}#{url}#{dataType}#{createBy}#{createTime}#{updateBy}#{updateTime}#{state})
insert into dataset(name,version,description,url,data_type,create_by,create_time,update_by,update_time,state)
values (#{dataset.name},#{dataset.version},#{dataset.description},#{dataset.url},#{dataset.dataType},#{dataset.createBy},#{dataset.createTime},#{dataset.updateBy},#{dataset.updateTime},#{dataset.state})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
@ -138,44 +138,41 @@ name = values(name)version = values(version)description = values(description)url
<update id="update">
update dataset
<set>
<if test="dataset.id != null">
and id = #{dataset.id}
</if>
<if test="dataset.name != null and dataset.name != ''">
and name = #{dataset.name}
name = #{dataset.name},
</if>
<if test="dataset.version != null and dataset.version != ''">
and version = #{dataset.version}
version = #{dataset.version},
</if>
<if test="dataset.description != null and dataset.description != ''">
and description = #{dataset.description}
description = #{dataset.description},
</if>
<if test="dataset.url != null and dataset.url != ''">
and url = #{dataset.url}
url = #{dataset.url},
</if>
<if test="dataset.dataType != null">
and data_type = #{dataset.dataType}
data_type = #{dataset.dataType},
</if>
<if test="dataset.createBy != null and dataset.createBy != ''">
and create_by = #{dataset.createBy}
create_by = #{dataset.createBy},
</if>
<if test="dataset.createTime != null">
and create_time = #{dataset.createTime}
create_time = #{dataset.createTime},
</if>
<if test="dataset.updateBy != null and dataset.updateBy != ''">
and update_by = #{dataset.updateBy}
update_by = #{dataset.updateBy},
</if>
<if test="dataset.updateTime != null">
and update_time = #{dataset.updateTime}
update_time = #{dataset.updateTime},
</if>
<if test="dataset.state != null">
and state = #{dataset.state}
state = #{dataset.state}
</if>
</set>
where id = #{id}
where id = #{dataset.id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from dataset where id = #{id}

View File

@ -8,6 +8,7 @@
<result property="argoInsName" column="argo_ins_name" jdbcType="VARCHAR"/>
<result property="argoInsNs" column="argo_ins_ns" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="nodesStatus" column="nodes_status" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
@ -21,21 +22,21 @@
<!--查询单个-->
<select id="queryById" resultMap="ExperimentInsMap">
select id,experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state
select id,experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state
from experiment_ins
where id = #{id} and state = 1
</select>
<!--查询列表-->
<select id="getByExperimentId" resultMap="ExperimentInsMap">
select id,experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state
select id,experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state
from experiment_ins
where experiment_id = #{experiment_id} and state = 1 order by create_time limit 5
</select>
<select id="queryByExperiment" resultMap="ExperimentInsMap">
select
id,experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state
id,experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state
from experiment_ins
<where>
state = 1
@ -54,6 +55,9 @@
<if test="experimentIns.status != null and experimentIns.status != ''">
and status = #{experimentIns.status}
</if>
<if test="experimentIns.nodesStatus != null and experimentIns.nodesStatus != ''">
and nodes_status = #{experimentIns.nodesStatus}
</if>
<if test="experimentIns.createBy != null and experimentIns.createBy != ''">
and create_by = #{experimentIns.createBy}
</if>
@ -90,6 +94,9 @@
<if test="experimentIns.status != null and experimentIns.status != ''">
and status = #{experimentIns.status}
</if>
<if test="experimentIns.nodesStatus != null and experimentIns.nodesStatus != ''">
and nodes_status = #{experimentIns.nodesStatus}
</if>
<if test="experimentIns.createBy != null and experimentIns.createBy != ''">
and create_by = #{experimentIns.createBy}
</if>
@ -127,6 +134,9 @@
<if test="experimentIns.status != null and experimentIns.status != ''">
and status = #{experimentIns.status}
</if>
<if test="experimentIns.nodesStatus != null and experimentIns.nodesStatus != ''">
and nodes_status = #{experimentIns.nodesStatus}
</if>
<if test="experimentIns.createBy != null and experimentIns.createBy != ''">
and create_by = #{experimentIns.createBy}
</if>
@ -144,29 +154,29 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state)
values (#{experimentId},#{argoInsName},#{argoInsNs},#{status},#{createBy},#{createTime},#{updateBy},#{updateTime},#{state})
insert into experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state)
values (#{experimentId},#{argoInsName},#{argoInsNs},#{status},#{nodesStatus},#{createBy},#{createTime},#{updateBy},#{updateTime},#{state})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state)
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.nodesStatus}#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state)
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.nodesStatus},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
</foreach>
on duplicate key update
experiment_id = values(experiment_id)argo_ins_name = values(argo_ins_name)argo_ins_ns =
values(argo_ins_ns)status = values(status)create_by = values(create_by)create_time =
values(argo_ins_ns)status = values(status) nodes_status = values(nodes_status) create_by = values(create_by)create_time =
values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
</insert>
@ -186,6 +196,9 @@
<if test="status != null and status != ''">
status = #{status},
</if>
<if test="nodesStatus != null and nodesStatus != ''">
nodes_status = #{nodesStatus},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>

View File

@ -21,7 +21,7 @@
select
id,name,version,description,url,model_type,create_by,create_time,update_by,update_time,state
from models
where id = #{id}
where id = #{id} and state = 1
</select>
<!--查询指定行数据-->
@ -112,12 +112,12 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into models(nameversiondescriptionurlmodel_typecreate_bycreate_timeupdate_byupdate_timestate)
values (#{name}#{version}#{description}#{url}#{modelType}#{createBy}#{createTime}#{updateBy}#{updateTime}#{state})
insert into models(name,version,description,url,model_type,create_by,create_time,update_by,update_time,state)
values (#{models.name},#{models.version},#{models.description},#{models.url},#{models.modelType},#{models.createBy},#{models.createTime},#{models.updateBy},#{models.updateTime},#{models.state})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into models(nameversiondescriptionurlmodel_typecreate_bycreate_timeupdate_byupdate_timestate)
insert into models(name,version,description,url,model_type,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}#{entity.version}#{entity.description}#{entity.url}#{entity.modelType}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
@ -125,7 +125,7 @@
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into models(nameversiondescriptionurlmodel_typecreate_bycreate_timeupdate_byupdate_timestate)
insert into models(name,version,description,url,model_type,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}#{entity.version}#{entity.description}#{entity.url}#{entity.modelType}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
@ -139,42 +139,43 @@ name = values(name)version = values(version)description = values(description)url
update models
<set>
<if test="models.id != null">
and id = #{models.id}
id = #{models.id},
</if>
<if test="models.name != null and models.name != ''">
and name = #{models.name}
name = #{models.name},
</if>
<if test="models.version != null and models.version != ''">
and version = #{models.version}
version = #{models.version},
</if>
<if test="models.description != null and models.description != ''">
and description = #{models.description}
description = #{models.description},
</if>
<if test="models.url != null and models.url != ''">
and url = #{models.url}
url = #{models.url},
</if>
<if test="models.modelType != null">
and model_type = #{models.modelType}
model_type = #{models.modelType},
</if>
<if test="models.createBy != null and models.createBy != ''">
and create_by = #{models.createBy}
create_by = #{models.createBy},
</if>
<if test="models.createTime != null">
and create_time = #{models.createTime}
create_time = #{models.createTime},
</if>
<if test="models.updateBy != null and models.updateBy != ''">
and update_by = #{models.updateBy}
update_by = #{models.updateBy},
</if>
<if test="models.updateTime != null">
and update_time = #{models.updateTime}
update_time = #{models.updateTime},
</if>
<if test="models.state != null">
and state = #{models.state}
state = #{models.state}
</if>
</set>
where id = #{id}
where id = #{models.id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from models where id = #{id}

View File

@ -74,7 +74,7 @@ public class ComponentController {
*/
@PutMapping
@ApiOperation("编辑组件")
public ResponseEntity<Component> edit(@RequestBody Component component) {
public ResponseEntity<Component> edit(@RequestBody ComponentVo component) {
return ResponseEntity.ok(this.componentService.update(component));
}

View File

@ -9,6 +9,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -32,7 +33,8 @@ public class DatasetController {
* 分页查询
*
* @param dataset 筛选条件
* @param pageRequest 分页对象
* @param page 页数
* @param size 大小
* @return 查询结果
*/
@GetMapping
@ -62,7 +64,7 @@ public class DatasetController {
*/
@PostMapping
@ApiOperation("添加数据集")
public ResponseEntity<Dataset> add(@RequestBody Dataset dataset) {
public ResponseEntity<Dataset> add(Dataset dataset) {
return ResponseEntity.ok(this.datasetService.insert(dataset));
}
@ -74,7 +76,7 @@ public class DatasetController {
*/
@PutMapping
@ApiOperation("编辑数据集")
public ResponseEntity<Dataset> edit(@RequestBody Dataset dataset) {
public ResponseEntity<Dataset> edit(Dataset dataset) {
return ResponseEntity.ok(this.datasetService.update(dataset));
}
@ -102,5 +104,12 @@ public class DatasetController {
return datasetService.downloadDataset(id);
}
@PostMapping("/upload/{id}")
@ApiOperation("上传数据集")
public ResponseEntity<String> uploadDataset(@RequestParam("file") MultipartFile file , @PathVariable("id") Integer id) throws Exception {
return ResponseEntity.ok(this.datasetService.uploadDataset(file,id));
}
}

View File

@ -84,9 +84,9 @@ public class ExperimentInsController {
* @param id 主键
* @return 删除是否成功
*/
@DeleteMapping
@DeleteMapping("{id}")
@ApiOperation("删除实验实例")
public ResponseEntity<String> deleteById(Integer id) {
public ResponseEntity<String> deleteById( @PathVariable("id") Integer id) {
return ResponseEntity.ok(this.experimentInsService.removeById(id));
}

View File

@ -3,6 +3,8 @@ package com.ruoyi.web.controller.jupyter;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.platform.service.JupyterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -12,10 +14,12 @@ import java.io.IOException;
@RestController
@RequestMapping("/jupyter")
@Api("jupyter service")
public class JupyterController extends BaseController {
@Resource
private JupyterService jupyterService;
@GetMapping(value = "/getURL")
@ApiOperation("得到访问地址")
public AjaxResult getURL() throws IOException {
return AjaxResult.success(jupyterService.getJupyterServiceUrl());
}

View File

@ -6,12 +6,12 @@ import com.ruoyi.platform.domain.*;
import com.ruoyi.platform.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.Model;
import org.springframework.core.io.InputStreamResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -35,7 +35,8 @@ public class ModelsController {
* 分页查询
*
* @param models 筛选条件
* @param pageRequest 分页对象
* @param page 分页对象
* @param size 分页对象
* @return 查询结果
*/
@GetMapping
@ -65,7 +66,7 @@ public class ModelsController {
*/
@PostMapping
@ApiOperation("添加模型")
public ResponseEntity<Models> add(@RequestBody Models models) {
public ResponseEntity<Models> add(Models models) {
return ResponseEntity.ok(this.modelsService.insert(models));
}
@ -77,7 +78,7 @@ public class ModelsController {
*/
@PutMapping
@ApiOperation("编辑模型")
public ResponseEntity<Models> edit(@RequestBody Models models) {
public ResponseEntity<Models> edit(Models models) {
return ResponseEntity.ok(this.modelsService.update(models));
}
@ -93,6 +94,23 @@ public class ModelsController {
return ResponseEntity.ok(this.modelsService.removeById(id));
}
/**
* 模型上传
*
*
*
* @param file 文件
* @return 上传结果
*/
@PostMapping("/upload/{id}")
@ApiOperation("上传数据集")
public ResponseEntity<String> uploadModels(@RequestParam("file") MultipartFile file, @PathVariable("id") Integer id) throws Exception {
return ResponseEntity.ok(this.modelsService.uploadModels(file,id));
}
/**
* 模型下载
*
@ -103,7 +121,9 @@ public class ModelsController {
*/
@GetMapping("/download/{id}")
@ApiOperation("下载模型")
public ResponseEntity<InputStreamResource> downloadModels(@PathVariable("id") Integer id) {
public ResponseEntity<InputStreamResource> downloadModels(@PathVariable("id") Integer id)
{
return modelsService.downloadModels(id);
}

View File

@ -61,7 +61,7 @@ public class ComputingResourceController {
*/
@PostMapping
@ApiOperation("新增计算资源")
public ResponseEntity<ComputingResource> add(@RequestBody ComputingResource computingResource) {
public ResponseEntity<ComputingResource> add(ComputingResource computingResource) {
return ResponseEntity.ok(this.computingResourceService.insert(computingResource));
}
@ -73,7 +73,7 @@ public class ComputingResourceController {
*/
@PutMapping
@ApiOperation("编辑计算资源")
public ResponseEntity<ComputingResource> edit(@RequestBody ComputingResource computingResource) {
public ResponseEntity<ComputingResource> edit(ComputingResource computingResource) {
return ResponseEntity.ok(this.computingResourceService.update(computingResource));
}

View File

@ -78,7 +78,7 @@ public class WorkflowController {
*/
@PostMapping
@ApiOperation("新增")
public ResponseEntity<Workflow> add(@RequestBody Workflow workflow) {
public ResponseEntity<Workflow> add(Workflow workflow) {
return ResponseEntity.ok(this.workflowService.insert(workflow));
}
@ -115,7 +115,7 @@ public class WorkflowController {
*/
@PutMapping
@ApiOperation("编辑流水线")
public ResponseEntity<Workflow> edit(@RequestBody Workflow workflow) {
public ResponseEntity<Workflow> edit(Workflow workflow) {
return ResponseEntity.ok(this.workflowService.update(workflow));
}