| @@ -5,6 +5,7 @@ import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.domain.DatasetVersion; | |||
| import com.ruoyi.platform.service.DatasetService; | |||
| import com.ruoyi.platform.service.DatasetVersionService; | |||
| import com.ruoyi.platform.vo.DatasetVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -83,6 +84,19 @@ public class DatasetController { | |||
| } | |||
| /** | |||
| * 新增数据 | |||
| * | |||
| * @param datasetVo 实体 | |||
| * @return 新增结果 | |||
| */ | |||
| @PostMapping("/addDatesetAndVesion") | |||
| @ApiOperation("添加数据集") | |||
| public AjaxResult addDatesetAndVesion(@RequestBody DatasetVo datasetVo) throws Exception { | |||
| return AjaxResult.success(this.datasetService.insertDatesetAndVesion(datasetVo)); | |||
| } | |||
| /** | |||
| * 编辑数据 | |||
| * | |||
| @@ -24,6 +24,8 @@ public class Dataset implements Serializable { | |||
| @ApiModelProperty(name = "description") | |||
| private String description; | |||
| @ApiModelProperty(name = "range") | |||
| private String range; | |||
| @ApiModelProperty(name = "data_type") | |||
| private Integer dataType; | |||
| @ApiModelProperty(name = "data_tag") | |||
| @@ -87,13 +89,13 @@ public class Dataset implements Serializable { | |||
| this.description = description; | |||
| } | |||
| // public String getUrl() { | |||
| // return url; | |||
| // } | |||
| // | |||
| // public void setUrl(String url) { | |||
| // this.url = url; | |||
| // } | |||
| public String getRange() { | |||
| return range; | |||
| } | |||
| public void setRange(String range) { | |||
| this.range = range; | |||
| } | |||
| public Integer getDataType() { | |||
| return dataType; | |||
| @@ -23,32 +23,32 @@ public class DatasetVersion implements Serializable { | |||
| private Integer id; | |||
| @ApiModelProperty(name = "dataset_id") | |||
| private Integer datasetId; | |||
| /** | |||
| /** | |||
| * 版本 | |||
| */ | |||
| @ApiModelProperty(name = "version") | |||
| private String version; | |||
| /** | |||
| /** | |||
| * 数据集存储地址 | |||
| */ | |||
| @ApiModelProperty(name = "url") | |||
| private String url; | |||
| /** | |||
| /** | |||
| * 文件名 | |||
| */ | |||
| @ApiModelProperty(name = "file_name") | |||
| private String fileName; | |||
| /** | |||
| /** | |||
| * 文件大小 | |||
| */ | |||
| @ApiModelProperty(name = "file_size") | |||
| private String fileSize; | |||
| /** | |||
| /** | |||
| * 可用集群 | |||
| */ | |||
| @ApiModelProperty(name = "available_cluster") | |||
| private String availableCluster; | |||
| /** | |||
| /** | |||
| * 状态 | |||
| */ | |||
| @ApiModelProperty(name = "status") | |||
| @@ -2,6 +2,7 @@ package com.ruoyi.platform.service; | |||
| import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.domain.DatasetVersion; | |||
| import com.ruoyi.platform.vo.DatasetVo; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| @@ -74,4 +75,6 @@ public interface DatasetService { | |||
| Map uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception; | |||
| Map getDatasetVersions(Integer datasetId) throws Exception; | |||
| String insertDatesetAndVesion(DatasetVo datasetVo) throws Exception; | |||
| } | |||
| @@ -12,8 +12,10 @@ import com.ruoyi.platform.service.DatasetService; | |||
| import com.ruoyi.platform.service.DatasetVersionService; | |||
| import com.ruoyi.platform.utils.BeansUtils; | |||
| import com.ruoyi.platform.utils.MinioUtil; | |||
| import com.ruoyi.platform.vo.DatasetVo; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import io.minio.MinioClient; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| @@ -25,6 +27,7 @@ import org.springframework.http.HttpStatus; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.annotation.Resource; | |||
| @@ -315,6 +318,33 @@ public class DatasetServiceImpl implements DatasetService { | |||
| return versions.stream().collect(Collectors.groupingBy(DatasetVersion::getVersion)); | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public String insertDatesetAndVesion(DatasetVo datasetVo) throws Exception { | |||
| Dataset dataset = new Dataset(); | |||
| dataset.setName(datasetVo.getName()); | |||
| dataset.setDescription(datasetVo.getDescription()); | |||
| dataset.setRange(datasetVo.getRange()); | |||
| dataset.setDataType(datasetVo.getDataType()); | |||
| dataset.setDataTag(datasetVo.getDataTag()); | |||
| Dataset insert = this.insert(dataset); | |||
| if (insert == null){ | |||
| throw new Exception("新增数据集失败"); | |||
| } | |||
| DatasetVersion datasetVersion = new DatasetVersion(); | |||
| datasetVersion.setDatasetId(insert.getId()); | |||
| datasetVersion.setVersion(datasetVo.getVersion()); | |||
| datasetVersion.setUrl(datasetVo.getUrl()); | |||
| datasetVersion.setFileName(datasetVo.getFileName()); | |||
| datasetVersion.setFileSize(datasetVo.getFileSize()); | |||
| datasetVersion.setAvailableCluster(datasetVo.getAvailableCluster()); | |||
| DatasetVersion datasetVersionInsert = datasetVersionService.insert(datasetVersion); | |||
| if (datasetVersionInsert == null) { | |||
| throw new Exception("新增数据集失败"); | |||
| } | |||
| return "新增数据集成功"; | |||
| } | |||
| private String extractFileName(String urlStr) { | |||
| return urlStr.substring(urlStr.lastIndexOf('/') + 1); | |||
| @@ -0,0 +1,132 @@ | |||
| package com.ruoyi.platform.vo; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import java.io.Serializable; | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| public class DatasetVo implements Serializable { | |||
| @ApiModelProperty(name = "name") | |||
| private String name; | |||
| @ApiModelProperty(name = "description") | |||
| private String description; | |||
| /** | |||
| * 是否公开1公开,0私有 | |||
| */ | |||
| @ApiModelProperty(name = "range") | |||
| private String range; | |||
| @ApiModelProperty(name = "data_type") | |||
| private Integer dataType; | |||
| @ApiModelProperty(name = "data_tag") | |||
| private Integer dataTag; | |||
| /** | |||
| * 版本 | |||
| */ | |||
| @ApiModelProperty(name = "version") | |||
| private String version; | |||
| /** | |||
| * 数据集存储地址 | |||
| */ | |||
| @ApiModelProperty(name = "url") | |||
| private String url; | |||
| /** | |||
| * 文件名 | |||
| */ | |||
| @ApiModelProperty(name = "file_name") | |||
| private String fileName; | |||
| /** | |||
| * 文件大小 | |||
| */ | |||
| @ApiModelProperty(name = "file_size") | |||
| private String fileSize; | |||
| /** | |||
| * 可用集群 | |||
| */ | |||
| @ApiModelProperty(name = "available_cluster") | |||
| private String availableCluster; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getDescription() { | |||
| return description; | |||
| } | |||
| public void setDescription(String description) { | |||
| this.description = description; | |||
| } | |||
| public String getRange() { | |||
| return range; | |||
| } | |||
| public void setRange(String range) { | |||
| this.range = range; | |||
| } | |||
| public Integer getDataType() { | |||
| return dataType; | |||
| } | |||
| public void setDataType(Integer dataType) { | |||
| this.dataType = dataType; | |||
| } | |||
| public Integer getDataTag() { | |||
| return dataTag; | |||
| } | |||
| public void setDataTag(Integer dataTag) { | |||
| this.dataTag = dataTag; | |||
| } | |||
| public String getVersion() { | |||
| return version; | |||
| } | |||
| public void setVersion(String version) { | |||
| this.version = version; | |||
| } | |||
| public String getUrl() { | |||
| return url; | |||
| } | |||
| public void setUrl(String url) { | |||
| this.url = url; | |||
| } | |||
| public String getFileName() { | |||
| return fileName; | |||
| } | |||
| public void setFileName(String fileName) { | |||
| this.fileName = fileName; | |||
| } | |||
| public String getFileSize() { | |||
| return fileSize; | |||
| } | |||
| public void setFileSize(String fileSize) { | |||
| this.fileSize = fileSize; | |||
| } | |||
| public String getAvailableCluster() { | |||
| return availableCluster; | |||
| } | |||
| public void setAvailableCluster(String availableCluster) { | |||
| this.availableCluster = availableCluster; | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| package com.ruoyi.platform.vo; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import java.io.Serializable; | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| public class ModelsVo implements Serializable { | |||
| @ApiModelProperty(name = "name") | |||
| private String name; | |||
| // private String version; | |||
| @ApiModelProperty(name = "description") | |||
| private String description; | |||
| // private String url; | |||
| @ApiModelProperty(name = "model_type") | |||
| private Integer modelType; | |||
| @ApiModelProperty(name = "model_tag") | |||
| private Integer modelTag; | |||
| /** | |||
| * 版本 | |||
| */ | |||
| @ApiModelProperty(name = "version") | |||
| private String version; | |||
| /** | |||
| * 模型存储地址 | |||
| */ | |||
| @ApiModelProperty(name = "url") | |||
| private String url; | |||
| /** | |||
| * 文件名 | |||
| */ | |||
| @ApiModelProperty(name = "file_name") | |||
| private String fileName; | |||
| /** | |||
| * 文件大小 | |||
| */ | |||
| @ApiModelProperty(name = "file_size") | |||
| private String fileSize; | |||
| /** | |||
| * 状态 | |||
| */ | |||
| @ApiModelProperty(name = "status") | |||
| private Integer status; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getDescription() { | |||
| return description; | |||
| } | |||
| public void setDescription(String description) { | |||
| this.description = description; | |||
| } | |||
| public Integer getModelType() { | |||
| return modelType; | |||
| } | |||
| public void setModelType(Integer modelType) { | |||
| this.modelType = modelType; | |||
| } | |||
| public Integer getModelTag() { | |||
| return modelTag; | |||
| } | |||
| public void setModelTag(Integer modelTag) { | |||
| this.modelTag = modelTag; | |||
| } | |||
| public String getVersion() { | |||
| return version; | |||
| } | |||
| public void setVersion(String version) { | |||
| this.version = version; | |||
| } | |||
| public String getUrl() { | |||
| return url; | |||
| } | |||
| public void setUrl(String url) { | |||
| this.url = url; | |||
| } | |||
| public String getFileName() { | |||
| return fileName; | |||
| } | |||
| public void setFileName(String fileName) { | |||
| this.fileName = fileName; | |||
| } | |||
| public String getFileSize() { | |||
| return fileSize; | |||
| } | |||
| public void setFileSize(String fileSize) { | |||
| this.fileSize = fileSize; | |||
| } | |||
| public Integer getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(Integer status) { | |||
| this.status = status; | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| <result property="id" column="id" jdbcType="INTEGER"/> | |||
| <result property="name" column="name" jdbcType="VARCHAR"/> | |||
| <result property="description" column="description" jdbcType="VARCHAR"/> | |||
| <result property="range" column="range" jdbcType="INTEGER"/> | |||
| <result property="dataType" column="data_type" jdbcType="INTEGER"/> | |||
| <result property="dataTag" column="data_tag" jdbcType="INTEGER"/> | |||
| <result property="createBy" column="create_by" jdbcType="VARCHAR"/> | |||
| @@ -18,7 +19,7 @@ | |||
| <!--查询单个--> | |||
| <select id="queryById" resultMap="DatasetMap"> | |||
| select | |||
| id,name,description,data_type,data_tag,create_by,create_time,update_by,update_time,state | |||
| id,name,description,range,data_type,data_tag,create_by,create_time,update_by,update_time,state | |||
| from dataset | |||
| where id = #{id} and state = 1 | |||
| </select> | |||
| @@ -26,7 +27,7 @@ | |||
| <!--查询指定行数据--> | |||
| <select id="queryAllByLimit" resultMap="DatasetMap"> | |||
| select | |||
| id,name,description,data_type,data_tag,create_by,create_time,update_by,update_time,state | |||
| id,name,description,range,data_type,data_tag,create_by,create_time,update_by,update_time,state | |||
| from dataset | |||
| <where> | |||
| state = 1 | |||
| @@ -39,6 +40,9 @@ | |||
| <if test="dataset.description != null and dataset.description != ''"> | |||
| and description = #{dataset.description} | |||
| </if> | |||
| <if test="dataset.range != null and dataset.range != ''"> | |||
| and range = #{dataset.range} | |||
| </if> | |||
| <if test="dataset.dataType != null"> | |||
| and data_type = #{dataset.dataType} | |||
| </if> | |||
| @@ -79,6 +83,9 @@ | |||
| <if test="dataset.description != null and dataset.description != ''"> | |||
| and description = #{dataset.description} | |||
| </if> | |||
| <if test="dataset.range != null and dataset.range != ''"> | |||
| and range = #{dataset.range} | |||
| </if> | |||
| <if test="dataset.dataType != null"> | |||
| and data_type = #{dataset.dataType} | |||
| </if> | |||
| @@ -105,26 +112,26 @@ | |||
| <!--新增所有列--> | |||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into dataset(name,description,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| values (#{dataset.name},#{dataset.description},#{dataset.dataType},#{dataset.dataTag},#{dataset.createBy},#{dataset.createTime},#{dataset.updateBy},#{dataset.updateTime},#{dataset.state}) | |||
| insert into dataset(name,description,range,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| values (#{dataset.name},#{dataset.description},#{dataset.range},#{dataset.dataType},#{dataset.dataTag},#{dataset.createBy},#{dataset.createTime},#{dataset.updateBy},#{dataset.updateTime},#{dataset.state}) | |||
| </insert> | |||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into dataset(name,description,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| insert into dataset(name,description,range,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| values | |||
| <foreach collection="entities" item="entity" separator=","> | |||
| (#{entity.name}#{entity.description}#{entity.dataType}#{entity.dataTag}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||
| (#{entity.name}#{entity.description}#{entity.range}#{entity.dataType}#{entity.dataTag}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||
| </foreach> | |||
| </insert> | |||
| <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into dataset(name,description,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| insert into dataset(name,description,range,data_type,data_tag,create_by,create_time,update_by,update_time,state) | |||
| values | |||
| <foreach collection="entities" item="entity" separator=","> | |||
| (#{entity.name}#{entity.description}#{entity.dataType}#{entity.dataTag}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||
| (#{entity.name}#{entity.description}#{entity.range#{entity.dataType}#{entity.dataTag}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||
| </foreach> | |||
| on duplicate key update | |||
| name = values(name)description = values(description)data_type = values(data_type)data_tag = values(data_tag)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state) | |||
| name = values(name)description = values(description)range = values(range)data_type = values(data_type)data_tag = values(data_tag)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state) | |||
| </insert> | |||
| <!--通过主键修改数据--> | |||
| @@ -137,11 +144,14 @@ | |||
| <if test="dataset.description != null and dataset.description != ''"> | |||
| description = #{dataset.description}, | |||
| </if> | |||
| <if test="dataset.range != null and dataset.range != ''"> | |||
| range = #{dataset.range} | |||
| </if>, | |||
| <if test="dataset.dataType != null"> | |||
| data_type = #{dataset.dataType}, | |||
| </if> | |||
| <if test="dataset.dataTag != null"> | |||
| and data_tag = #{dataset.dataTag} | |||
| data_tag = #{dataset.dataTag} | |||
| </if> | |||
| <if test="dataset.createBy != null and dataset.createBy != ''"> | |||
| create_by = #{dataset.createBy}, | |||