| @@ -7,8 +7,6 @@ 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; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| import org.springframework.data.domain.PageRequest; | |||
| @@ -90,10 +88,10 @@ public class DatasetController { | |||
| * @param datasetVo 实体 | |||
| * @return 新增结果 | |||
| */ | |||
| @PostMapping("/addDatesetAndVesion") | |||
| @PostMapping("/addDatasetAndVersion") | |||
| @ApiOperation("添加数据集和版本") | |||
| public AjaxResult addDatesetAndVesion(@RequestBody DatasetVo datasetVo) throws Exception { | |||
| return AjaxResult.success(this.datasetService.insertDatesetAndVesion(datasetVo)); | |||
| public AjaxResult addDatasetAndVersion(@RequestBody DatasetVo datasetVo) throws Exception { | |||
| return AjaxResult.success(this.datasetService.insertDatasetAndVersion(datasetVo)); | |||
| } | |||
| @@ -5,6 +5,8 @@ import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.platform.domain.Models; | |||
| import com.ruoyi.platform.domain.ModelsVersion; | |||
| import com.ruoyi.platform.service.ModelsService; | |||
| import com.ruoyi.platform.vo.DatasetVo; | |||
| import com.ruoyi.platform.vo.ModelsVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| @@ -77,6 +79,19 @@ public class ModelsController { | |||
| return AjaxResult.success(this.modelsService.insert(models)); | |||
| } | |||
| /** | |||
| * 新增数据 | |||
| * | |||
| * @param modelsVo 实体 | |||
| * @return 新增结果 | |||
| */ | |||
| @PostMapping("/addModelAndVersion") | |||
| @ApiOperation("添加模型和版本") | |||
| public AjaxResult addModelAndVersion(@RequestBody ModelsVo modelsVo) throws Exception { | |||
| return AjaxResult.success(this.modelsService.insertModelAndVersion(modelsVo)); | |||
| } | |||
| /** | |||
| * 编辑数据 | |||
| * | |||
| @@ -63,6 +63,10 @@ public class Image implements Serializable { | |||
| @ApiModelProperty(name = "state") | |||
| private Integer state; | |||
| private Integer versionCount; // 版本数量统计 | |||
| public Integer getId() { | |||
| return id; | |||
| @@ -128,6 +132,15 @@ public class Image implements Serializable { | |||
| this.updateTime = updateTime; | |||
| } | |||
| // Getter 和 Setter | |||
| public Integer getVersionCount() { | |||
| return versionCount; | |||
| } | |||
| public void setVersionCount(int versionCount) { | |||
| this.versionCount = versionCount; | |||
| } | |||
| public Integer getState() { | |||
| return state; | |||
| } | |||
| @@ -25,7 +25,15 @@ public class Models implements Serializable { | |||
| @ApiModelProperty(name = "description") | |||
| private String description; | |||
| // private String url; | |||
| /** | |||
| * 模型可见范围 | |||
| */ | |||
| @ApiModelProperty(name = "available_range") | |||
| private int availableRange; | |||
| @ApiModelProperty(name = "model_type") | |||
| private Integer modelType; | |||
| @ApiModelProperty(name = "model_tag") | |||
| @@ -35,6 +43,9 @@ public class Models implements Serializable { | |||
| */ | |||
| @ApiModelProperty(name = "create_by") | |||
| private String createBy; | |||
| /** | |||
| * 创建时间 | |||
| */ | |||
| @@ -81,6 +92,15 @@ public class Models implements Serializable { | |||
| // this.version = version; | |||
| // } | |||
| public int getAvailableRange() { | |||
| return availableRange; | |||
| } | |||
| public void setAvailableRange(int availableRange) { | |||
| this.availableRange = availableRange; | |||
| } | |||
| public String getDescription() { | |||
| return description; | |||
| } | |||
| @@ -76,5 +76,5 @@ public interface DatasetService { | |||
| Map getDatasetVersions(Integer datasetId) throws Exception; | |||
| String insertDatesetAndVesion(DatasetVo datasetVo) throws Exception; | |||
| String insertDatasetAndVersion(DatasetVo datasetVo) throws Exception; | |||
| } | |||
| @@ -4,6 +4,7 @@ package com.ruoyi.platform.service; | |||
| import com.ruoyi.platform.domain.Models; | |||
| import com.ruoyi.platform.domain.ModelsVersion; | |||
| import com.ruoyi.platform.vo.ModelsVo; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| @@ -74,4 +75,6 @@ public interface ModelsService { | |||
| ResponseEntity<InputStreamResource> downloadAllModelFiles(Integer modelsId, String version); | |||
| Map getModelVersions(Integer modelId) throws Exception; | |||
| String insertModelAndVersion(ModelsVo modelsVo) throws Exception; | |||
| } | |||
| @@ -320,19 +320,19 @@ public class DatasetServiceImpl implements DatasetService { | |||
| @Override | |||
| @Transactional | |||
| public String insertDatesetAndVesion(DatasetVo datasetVo) throws Exception { | |||
| public String insertDatasetAndVersion(DatasetVo datasetVo) throws Exception { | |||
| Dataset dataset = new Dataset(); | |||
| dataset.setName(datasetVo.getName()); | |||
| dataset.setDescription(datasetVo.getDescription()); | |||
| dataset.setAvailableRange(datasetVo.getAvailableRange()); | |||
| dataset.setDataType(datasetVo.getDataType()); | |||
| dataset.setDataTag(datasetVo.getDataTag()); | |||
| Dataset insert = this.insert(dataset); | |||
| if (insert == null){ | |||
| Dataset datasetInsert = this.insert(dataset); | |||
| if (datasetInsert == null){ | |||
| throw new Exception("新增数据集失败"); | |||
| } | |||
| DatasetVersion datasetVersion = new DatasetVersion(); | |||
| datasetVersion.setDatasetId(insert.getId()); | |||
| datasetVersion.setDatasetId(datasetInsert.getId()); | |||
| datasetVersion.setVersion(datasetVo.getVersion()); | |||
| datasetVersion.setUrl(datasetVo.getUrl()); | |||
| datasetVersion.setFileName(datasetVo.getFileName()); | |||
| @@ -1,6 +1,8 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.domain.DatasetVersion; | |||
| import com.ruoyi.platform.domain.Models; | |||
| import com.ruoyi.platform.domain.ModelsVersion; | |||
| import com.ruoyi.platform.mapper.ModelsDao; | |||
| @@ -9,6 +11,7 @@ import com.ruoyi.platform.service.ModelsService; | |||
| import com.ruoyi.platform.service.ModelsVersionService; | |||
| import com.ruoyi.platform.utils.BeansUtils; | |||
| import com.ruoyi.platform.utils.MinioUtil; | |||
| import com.ruoyi.platform.vo.ModelsVo; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import io.minio.MinioClient; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -22,6 +25,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; | |||
| @@ -361,6 +365,33 @@ public class ModelsServiceImpl implements ModelsService { | |||
| return versions.stream().collect(Collectors.groupingBy(ModelsVersion::getVersion)); | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public String insertModelAndVersion(ModelsVo modelsVo) throws Exception { | |||
| Models models = new Models(); | |||
| models.setName(modelsVo.getName()); | |||
| models.setDescription(modelsVo.getDescription()); | |||
| models.setAvailableRange(modelsVo.getAvailableRange()); | |||
| models.setModelType(modelsVo.getModelType()); | |||
| models.setModelTag(modelsVo.getModelTag()); | |||
| Models modelsInsert = this.insert(models); | |||
| if (modelsInsert == null){ | |||
| throw new Exception("新增模型失败"); | |||
| } | |||
| ModelsVersion modelsVersion = new ModelsVersion(); | |||
| modelsVersion.setModelsId(modelsInsert.getId()); | |||
| modelsVersion.setVersion(modelsVo.getVersion()); | |||
| modelsVersion.setUrl(modelsVo.getUrl()); | |||
| modelsVersion.setFileName(modelsVo.getFileName()); | |||
| modelsVersion.setFileSize(modelsVo.getFileSize()); | |||
| ModelsVersion modelsVersionInsert = this.modelsVersionService.insert(modelsVersion); | |||
| if (modelsVersionInsert == null) { | |||
| throw new Exception("新增模型失败"); | |||
| } | |||
| return "新增模型成功"; | |||
| } | |||
| private String extractFileName(String urlStr) { | |||
| return urlStr.substring(urlStr.lastIndexOf('/') + 1); | |||
| } | |||
| @@ -7,7 +7,7 @@ import io.swagger.annotations.ApiModelProperty; | |||
| import java.io.Serializable; | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| public class ModelsVo implements Serializable { | |||
| public class ModelsVo implements Serializable { | |||
| @ApiModelProperty(name = "name") | |||
| @@ -17,6 +17,13 @@ public class ModelsVo implements Serializable { | |||
| @ApiModelProperty(name = "description") | |||
| private String description; | |||
| /** | |||
| * 模型可见范围 | |||
| */ | |||
| @ApiModelProperty(name = "available_range") | |||
| private int availableRange; | |||
| // private String url; | |||
| @ApiModelProperty(name = "model_type") | |||
| private Integer modelType; | |||
| @@ -65,6 +72,15 @@ public class ModelsVo implements Serializable { | |||
| this.description = description; | |||
| } | |||
| public int getAvailableRange() { | |||
| return availableRange; | |||
| } | |||
| public void setAvailableRange(int availableRange) { | |||
| this.availableRange = availableRange; | |||
| } | |||
| public Integer getModelType() { | |||
| return modelType; | |||
| } | |||
| @@ -25,41 +25,43 @@ | |||
| <!--查询指定行数据--> | |||
| <select id="queryAllByLimit" resultMap="ImageMap"> | |||
| select | |||
| id, name, description, image_type, create_by, create_time, update_by, update_time, state | |||
| from image | |||
| img.id, img.name, img.description, img.image_type, img.create_by, img.create_time, img.update_by, img.update_time, img.state, | |||
| (SELECT COUNT(*) FROM image_version WHERE image_version.image_id = img.id) as versionCount | |||
| from image img | |||
| <where> | |||
| state = 1 | |||
| img.state = 1 | |||
| <if test="image.id != null"> | |||
| and id = #{image.id} | |||
| and img.id = #{image.id} | |||
| </if> | |||
| <if test="image.name != null and image.name != ''"> | |||
| and name = #{image.name} | |||
| and img.name = #{image.name} | |||
| </if> | |||
| <if test="image.description != null and image.description != ''"> | |||
| and description = #{image.description} | |||
| and img.description = #{image.description} | |||
| </if> | |||
| <if test="image.imageType != null"> | |||
| and image_type = #{image.imageType} | |||
| and img.image_type = #{image.imageType} | |||
| </if> | |||
| <if test="image.createBy != null and image.createBy != ''"> | |||
| and create_by = #{image.createBy} | |||
| and img.create_by = #{image.createBy} | |||
| </if> | |||
| <if test="image.createTime != null"> | |||
| and create_time = #{image.createTime} | |||
| and img.create_time = #{image.createTime} | |||
| </if> | |||
| <if test="image.updateBy != null and image.updateBy != ''"> | |||
| and update_by = #{image.updateBy} | |||
| and img.update_by = #{image.updateBy} | |||
| </if> | |||
| <if test="image.updateTime != null"> | |||
| and update_time = #{image.updateTime} | |||
| and img.update_time = #{image.updateTime} | |||
| </if> | |||
| <if test="image.state != null and image.state != ''"> | |||
| and state = #{image.state} | |||
| and img.state = #{image.state} | |||
| </if> | |||
| </where> | |||
| limit #{pageable.offset}, #{pageable.pageSize} | |||
| </select> | |||
| <!--通过镜像名字进行模糊查询--> | |||
| <select id="queryByName" resultMap="ImageMap"> | |||
| select | |||
| @@ -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="availableRange" column="available_range" jdbcType="INTEGER"/> | |||
| <result property="modelType" column="model_type" jdbcType="INTEGER"/> | |||
| <result property="modelTag" column="model_tag" jdbcType="INTEGER"/> | |||
| <result property="createBy" column="create_by" jdbcType="VARCHAR"/> | |||
| @@ -18,7 +19,7 @@ | |||
| <!--查询单个--> | |||
| <select id="queryById" resultMap="ModelsMap"> | |||
| select | |||
| id, name, description, model_type,model_tag, create_by, create_time, update_by, update_time, state | |||
| id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state | |||
| from models | |||
| where id = #{id} and state = 1 | |||
| </select> | |||
| @@ -26,7 +27,7 @@ | |||
| <!--查询指定行数据--> | |||
| <select id="queryAllByLimit" resultMap="ModelsMap"> | |||
| select | |||
| id, name, description, model_type,model_tag, create_by, create_time, update_by, update_time, state | |||
| id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state | |||
| from models | |||
| <where> | |||
| state = 1 | |||
| @@ -39,6 +40,9 @@ | |||
| <if test="models.description != null and models.description != ''"> | |||
| and description = #{models.description} | |||
| </if> | |||
| <if test="models.availableRange != null and models.availableRange != ''"> | |||
| and available_range = #{models.availableRange} | |||
| </if> | |||
| <if test="models.modelType != null"> | |||
| and model_type = #{models.modelType} | |||
| </if> | |||
| @@ -79,6 +83,9 @@ | |||
| <if test="models.description != null and models.description != ''"> | |||
| and description = #{models.description} | |||
| </if> | |||
| <if test="models.availableRange != null and models.availableRange != ''"> | |||
| and available_range = #{models.availableRange} | |||
| </if> | |||
| <if test="models.modelType != null"> | |||
| and model_type = #{models.modelType} | |||
| </if> | |||
| @@ -105,27 +112,28 @@ | |||
| <!--新增所有列--> | |||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into models(name, description, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| values (#{models.name}, #{models.description}, #{models.modelType}, #{models.modelTag}, #{models.createBy}, #{models.createTime}, #{models.updateBy}, #{models.updateTime}, #{models.state}) | |||
| insert into models(name, description, available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| values (#{models.name}, #{models.description},#{models.availableRange}, #{models.modelType}, #{models.modelTag}, #{models.createBy}, #{models.createTime}, #{models.updateBy}, #{models.updateTime}, #{models.state}) | |||
| </insert> | |||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into models(name, description, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| insert into models(name, description, available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| values | |||
| <foreach collection="entities" item="entity" separator=","> | |||
| (#{entity.name}, #{entity.description}, #{entity.modelType}, #{entity.modelTag}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) | |||
| (#{entity.name}, #{entity.description},#{models.availableRange}, #{entity.modelType}, #{entity.modelTag}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) | |||
| </foreach> | |||
| </insert> | |||
| <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into models(name, description, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| insert into models(name, description, available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state) | |||
| values | |||
| <foreach collection="entities" item="entity" separator=","> | |||
| (#{entity.name}, #{entity.description}, #{entity.modelType}, #{entity.modelTag}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) | |||
| (#{entity.name}, #{entity.description}, #{entity.availableRange},#{entity.modelType}, #{entity.modelTag}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) | |||
| </foreach> | |||
| on duplicate key update | |||
| name = values(name), | |||
| description = values(description), | |||
| available_range = values(available_range), | |||
| model_type = values(model_type), | |||
| model_tag = values(model_tag), | |||
| create_by = values(create_by), | |||
| @@ -145,6 +153,9 @@ | |||
| <if test="models.description != null and models.description != ''"> | |||
| description = #{models.description}, | |||
| </if> | |||
| <if test="models.availableRange != null and models.availableRange != ''"> | |||
| available_range = #{models.availableRange} | |||
| </if> | |||
| <if test="models.modelType != null"> | |||
| model_type = #{models.modelType}, | |||
| </if> | |||