| @@ -3,6 +3,8 @@ package com.ruoyi.platform.controller.dataset; | |||||
| import com.ruoyi.platform.domain.*; | import com.ruoyi.platform.domain.*; | ||||
| import com.ruoyi.platform.service.*; | import com.ruoyi.platform.service.*; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.core.io.InputStreamResource; | import org.springframework.core.io.InputStreamResource; | ||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| @@ -98,27 +100,33 @@ public class DatasetController { | |||||
| /** | /** | ||||
| * 下载数据集 | * 下载数据集 | ||||
| * | * | ||||
| * @param id ps:这里的id是dataset_version表的主键 | |||||
| * @param dataset_version_id ps:这里的id是dataset_version表的主键 | |||||
| * @return 单条数据 | * @return 单条数据 | ||||
| */ | */ | ||||
| @GetMapping("/download/{id}") | |||||
| @ApiOperation("下载数据集") | |||||
| public ResponseEntity<InputStreamResource> downloadDataset(@PathVariable("id") Integer id) { | |||||
| return datasetService.downloadDataset(id); | |||||
| @GetMapping("/download/{dataset_version_id}") | |||||
| @ApiOperation(value = "下载数据集", notes = "根据数据集版本表id下载数据集文件") | |||||
| public ResponseEntity<InputStreamResource> downloadDataset(@PathVariable("dataset_version_id") Integer dataset_version_id) { | |||||
| return datasetService.downloadDataset(dataset_version_id); | |||||
| } | } | ||||
| /** | /** | ||||
| * 上传数据集 | * 上传数据集 | ||||
| * | * | ||||
| * @param id ps:这里的id是dataset_version表的主键 | |||||
| * @param dataset_version_id ps:这里的id是dataset_version表的主键 | |||||
| * @param file 上传的数据集文件 | |||||
| * @return 上传结果 | * @return 上传结果 | ||||
| */ | */ | ||||
| @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)); | |||||
| @PostMapping("/upload/{dataset_version_id}") | |||||
| @ApiOperation(value = "上传数据集", notes = "根据数据集版本表id上传数据集文件,并将信息存入数据库。") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "file", value = "要上传的数据集文件", required = true, dataType = "file", paramType = "form"), | |||||
| @ApiImplicitParam(name = "dataset_version_id", value = "数据集版本表id", required = true, dataType = "integer", paramType = "path") | |||||
| }) | |||||
| public ResponseEntity<String> uploadDataset(@RequestParam("file") MultipartFile file, | |||||
| @PathVariable("dataset_version_id") Integer dataset_version_id) throws Exception { | |||||
| return ResponseEntity.ok(this.datasetService.uploadDataset(file, dataset_version_id)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -100,13 +100,14 @@ public class ModelsController { | |||||
| * | * | ||||
| * | * | ||||
| * @param file 文件 | * @param file 文件 | ||||
| * @param models_version_id 模型版本表主键 | |||||
| * @return 上传结果 | * @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)); | |||||
| @PostMapping("/upload/{models_version_id}") | |||||
| @ApiOperation(value = "上传模型", notes = "根据模型版本表id上传模型文件,并将信息存入数据库。") | |||||
| public ResponseEntity<String> uploadModels(@RequestParam("file") MultipartFile file, @PathVariable("models_version_id") Integer models_version_id) throws Exception { | |||||
| return ResponseEntity.ok(this.modelsService.uploadModels(file,models_version_id)); | |||||
| } | } | ||||
| @@ -114,17 +115,13 @@ public class ModelsController { | |||||
| /** | /** | ||||
| * 模型下载 | * 模型下载 | ||||
| * | * | ||||
| * | |||||
| * | |||||
| * @param id 主键 | |||||
| *@param models_version_id 模型版本表主键 | |||||
| * @return 单条数据 | * @return 单条数据 | ||||
| */ | */ | ||||
| @GetMapping("/download/{id}") | |||||
| @ApiOperation("下载模型") | |||||
| public ResponseEntity<InputStreamResource> downloadModels(@PathVariable("id") Integer id) | |||||
| { | |||||
| return modelsService.downloadModels(id); | |||||
| @GetMapping("/download/{models_version_id}") | |||||
| @ApiOperation(value = "下载模型", notes = "根据模型版本表id下载模型文件。") | |||||
| public ResponseEntity<InputStreamResource> downloadModels(@PathVariable("models_version_id") Integer models_version_id) { | |||||
| return modelsService.downloadModels(models_version_id); | |||||
| } | } | ||||
| } | } | ||||
| @@ -37,7 +37,7 @@ public interface WorkflowDao { | |||||
| * @param workflow 查询条件 | * @param workflow 查询条件 | ||||
| * @return 总行数 | * @return 总行数 | ||||
| */ | */ | ||||
| long count(@Param("workflow")Workflow workflow); | |||||
| long count(@Param("workflow") Workflow workflow); | |||||
| /** | /** | ||||
| * 新增数据 | * 新增数据 | ||||
| @@ -45,7 +45,7 @@ public interface WorkflowDao { | |||||
| * @param workflow 实例对象 | * @param workflow 实例对象 | ||||
| * @return 影响行数 | * @return 影响行数 | ||||
| */ | */ | ||||
| int insert(Workflow workflow); | |||||
| int insert(@Param("workflow") Workflow workflow); | |||||
| /** | /** | ||||
| * 批量新增数据(MyBatis原生foreach方法) | * 批量新增数据(MyBatis原生foreach方法) | ||||
| @@ -70,7 +70,7 @@ public interface WorkflowDao { | |||||
| * @param workflow 实例对象 | * @param workflow 实例对象 | ||||
| * @return 影响行数 | * @return 影响行数 | ||||
| */ | */ | ||||
| int update(Workflow workflow); | |||||
| int update(@Param("workflow") Workflow workflow); | |||||
| /** | /** | ||||
| * 通过主键删除数据 | * 通过主键删除数据 | ||||
| @@ -86,6 +86,6 @@ public interface WorkflowDao { | |||||
| * @param name 主键 | * @param name 主键 | ||||
| * @return 对象列表 | * @return 对象列表 | ||||
| */ | */ | ||||
| List<Workflow> queryByName(String name); | |||||
| List<Workflow> queryByName(@Param("name") String name); | |||||
| } | } | ||||
| @@ -213,6 +213,9 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| if(file.isEmpty()){ | if(file.isEmpty()){ | ||||
| throw new Exception("文件为空,无法上传"); | throw new Exception("文件为空,无法上传"); | ||||
| } | } | ||||
| // 获取文件大小并转换为KB | |||||
| long sizeInBytes = file.getSize(); | |||||
| double sizeInKB = sizeInBytes / 1024.0; | |||||
| //拿到dataset表的id去查数据集名字 | //拿到dataset表的id去查数据集名字 | ||||
| DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); | DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); | ||||
| @@ -243,6 +246,7 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| // 更新数据库中dataset_version表url记录 | // 更新数据库中dataset_version表url记录 | ||||
| datasetVersion.setUrl(objectName); | datasetVersion.setUrl(objectName); | ||||
| datasetVersion.setFileName(fileName); | datasetVersion.setFileName(fileName); | ||||
| datasetVersion.setFileSize(String.valueOf(sizeInKB)); | |||||
| datasetVersionDao.update(datasetVersion); | datasetVersionDao.update(datasetVersion); | ||||
| return "数据集成功上传到: " + objectName; | return "数据集成功上传到: " + objectName; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -202,6 +202,10 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| if(file.isEmpty()){ | if(file.isEmpty()){ | ||||
| throw new Exception("文件为空,无法上传"); | throw new Exception("文件为空,无法上传"); | ||||
| } | } | ||||
| // 获取文件大小并转换为KB | |||||
| long sizeInBytes = file.getSize(); | |||||
| double sizeInKB = sizeInBytes / 1024.0; | |||||
| //拿到models表的id去查模型名字 | //拿到models表的id去查模型名字 | ||||
| ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id); | ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id); | ||||
| if (modelsVersion == null){ | if (modelsVersion == null){ | ||||
| @@ -231,6 +235,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| // 更新数据库url | // 更新数据库url | ||||
| modelsVersion.setUrl(objectName); | modelsVersion.setUrl(objectName); | ||||
| modelsVersion.setFileName(fileName); | modelsVersion.setFileName(fileName); | ||||
| modelsVersion.setFileSize(String.valueOf(sizeInKB)); | |||||
| modelsVersionDao.update(modelsVersion); | modelsVersionDao.update(modelsVersion); | ||||
| return "模型成功上传到: " + objectName; | return "模型成功上传到: " + objectName; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -19,7 +19,7 @@ | |||||
| select | select | ||||
| id, name, description, dag, create_by, create_time, update_by, update_time, state | id, name, description, dag, create_by, create_time, update_by, update_time, state | ||||
| from workflow | from workflow | ||||
| where id = #{id} and state = 1 | |||||
| where id = #{id} and state = 1 | |||||
| </select> | </select> | ||||
| <!--查询指定行数据--> | <!--查询指定行数据--> | ||||
| @@ -92,10 +92,12 @@ | |||||
| <!--新增所有列--> | <!--新增所有列--> | ||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | ||||
| insert into workflow(name, description, dag, create_by, create_time, update_by, update_time, state) | |||||
| values (#{name}, #{description}, #{dag}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{state}) | |||||
| insert into workflow(name, description, dag, create_by, create_time, update_by, update_time,state) | |||||
| values (#{workflow.name}, #{workflow.description}, #{workflow.dag}, #{workflow.createBy}, #{workflow.createTime}, #{workflow.updateBy}, #{workflow.updateTime}, #{workflow.state}) | |||||
| </insert> | </insert> | ||||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | ||||
| insert into workflow(name, description, dag, create_by, create_time, update_by, update_time, state) | insert into workflow(name, description, dag, create_by, create_time, update_by, update_time, state) | ||||
| values | values | ||||
| @@ -127,32 +129,32 @@ | |||||
| <update id="update"> | <update id="update"> | ||||
| update workflow | update workflow | ||||
| <set> | <set> | ||||
| <if test="name != null and name != ''"> | |||||
| name = #{name}, | |||||
| <if test="workflow.name != null and workflow.name != ''"> | |||||
| name = #{workflow.name}, | |||||
| </if> | </if> | ||||
| <if test="description != null and description != ''"> | |||||
| description = #{description}, | |||||
| <if test="workflow.description != null and workflow.description != ''"> | |||||
| description = #{workflow.description}, | |||||
| </if> | </if> | ||||
| <if test="dag != null and dag != ''"> | |||||
| dag = #{dag}, | |||||
| <if test="workflow.dag != null and workflow.dag != ''"> | |||||
| dag = #{workflow.dag}, | |||||
| </if> | </if> | ||||
| <if test="createBy != null and createBy != ''"> | |||||
| create_by = #{createBy}, | |||||
| <if test="workflow.createBy != null and workflow.createBy != ''"> | |||||
| create_by = #{workflow.createBy}, | |||||
| </if> | </if> | ||||
| <if test="createTime != null"> | |||||
| create_time = #{createTime}, | |||||
| <if test="workflow.createTime != null"> | |||||
| create_time = #{workflow.createTime}, | |||||
| </if> | </if> | ||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| update_by = #{updateBy}, | |||||
| <if test="workflow.updateBy != null and workflow.updateBy != ''"> | |||||
| update_by = #{workflow.updateBy}, | |||||
| </if> | </if> | ||||
| <if test="updateTime != null"> | |||||
| update_time = #{updateTime}, | |||||
| <if test="workflow.updateTime != null"> | |||||
| update_time = #{workflow.updateTime}, | |||||
| </if> | </if> | ||||
| <if test="state != null"> | |||||
| state = #{state}, | |||||
| <if test="workflow.state != null"> | |||||
| state = #{workflow.state} | |||||
| </if> | </if> | ||||
| </set> | </set> | ||||
| where id = #{id} | |||||
| where id = #{workflow.id} | |||||
| </update> | </update> | ||||
| <!--通过主键删除--> | <!--通过主键删除--> | ||||
| @@ -167,8 +169,8 @@ | |||||
| from workflow | from workflow | ||||
| <where> | <where> | ||||
| state = 1 | state = 1 | ||||
| <if test="name != null and name != ''"> | |||||
| and name like "%"#{name}"%" | |||||
| <if test="workflow.name != null and workflow.name != ''"> | |||||
| and name like "%"#{workflow.name}"%" | |||||
| </if> | </if> | ||||
| </where> | </where> | ||||
| </select> | </select> | ||||