diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java index cc2b8e68..0b073607 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java @@ -3,6 +3,8 @@ package com.ruoyi.platform.controller.dataset; import com.ruoyi.platform.domain.*; import com.ruoyi.platform.service.*; 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.Page; @@ -98,27 +100,33 @@ public class DatasetController { /** * 下载数据集 * - * @param id ps:这里的id是dataset_version表的主键 + * @param dataset_version_id ps:这里的id是dataset_version表的主键 * @return 单条数据 */ - @GetMapping("/download/{id}") - @ApiOperation("下载数据集") - public ResponseEntity downloadDataset(@PathVariable("id") Integer id) { - return datasetService.downloadDataset(id); + @GetMapping("/download/{dataset_version_id}") + @ApiOperation(value = "下载数据集", notes = "根据数据集版本表id下载数据集文件") + public ResponseEntity 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 上传结果 */ - @PostMapping("/upload/{id}") - @ApiOperation("上传数据集") - public ResponseEntity 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 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)); } + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java index 79d124c5..beb61b7d 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java @@ -100,13 +100,14 @@ public class ModelsController { * * * @param file 文件 + * @param models_version_id 模型版本表主键 * @return 上传结果 */ - @PostMapping("/upload/{id}") - @ApiOperation("上传数据集") - public ResponseEntity 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 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 单条数据 */ - @GetMapping("/download/{id}") - @ApiOperation("下载模型") - public ResponseEntity downloadModels(@PathVariable("id") Integer id) - - { - return modelsService.downloadModels(id); + @GetMapping("/download/{models_version_id}") + @ApiOperation(value = "下载模型", notes = "根据模型版本表id下载模型文件。") + public ResponseEntity downloadModels(@PathVariable("models_version_id") Integer models_version_id) { + return modelsService.downloadModels(models_version_id); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java index 477429ae..b05e3ce6 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java @@ -37,7 +37,7 @@ public interface WorkflowDao { * @param workflow 查询条件 * @return 总行数 */ - long count(@Param("workflow")Workflow workflow); + long count(@Param("workflow") Workflow workflow); /** * 新增数据 @@ -45,7 +45,7 @@ public interface WorkflowDao { * @param workflow 实例对象 * @return 影响行数 */ - int insert(Workflow workflow); + int insert(@Param("workflow") Workflow workflow); /** * 批量新增数据(MyBatis原生foreach方法) @@ -70,7 +70,7 @@ public interface WorkflowDao { * @param workflow 实例对象 * @return 影响行数 */ - int update(Workflow workflow); + int update(@Param("workflow") Workflow workflow); /** * 通过主键删除数据 @@ -86,6 +86,6 @@ public interface WorkflowDao { * @param name 主键 * @return 对象列表 */ - List queryByName(String name); + List queryByName(@Param("name") String name); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java index 425992fa..54e570fe 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java @@ -213,6 +213,9 @@ public class DatasetServiceImpl implements DatasetService { if(file.isEmpty()){ throw new Exception("文件为空,无法上传"); } + // 获取文件大小并转换为KB + long sizeInBytes = file.getSize(); + double sizeInKB = sizeInBytes / 1024.0; //拿到dataset表的id去查数据集名字 DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); @@ -243,6 +246,7 @@ public class DatasetServiceImpl implements DatasetService { // 更新数据库中dataset_version表url记录 datasetVersion.setUrl(objectName); datasetVersion.setFileName(fileName); + datasetVersion.setFileSize(String.valueOf(sizeInKB)); datasetVersionDao.update(datasetVersion); return "数据集成功上传到: " + objectName; } catch (Exception e) { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index e0ba2305..b8097433 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -202,6 +202,10 @@ public class ModelsServiceImpl implements ModelsService { if(file.isEmpty()){ throw new Exception("文件为空,无法上传"); } + // 获取文件大小并转换为KB + long sizeInBytes = file.getSize(); + double sizeInKB = sizeInBytes / 1024.0; + //拿到models表的id去查模型名字 ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id); if (modelsVersion == null){ @@ -231,6 +235,7 @@ public class ModelsServiceImpl implements ModelsService { // 更新数据库url modelsVersion.setUrl(objectName); modelsVersion.setFileName(fileName); + modelsVersion.setFileSize(String.valueOf(sizeInKB)); modelsVersionDao.update(modelsVersion); return "模型成功上传到: " + objectName; } catch (Exception e) { diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml index 5123d2fe..ba2e313c 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml @@ -19,7 +19,7 @@ select id, name, description, dag, create_by, create_time, update_by, update_time, state from workflow - where id = #{id} and state = 1 + where id = #{id} and state = 1 @@ -92,10 +92,12 @@ - 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 into workflow(name, description, dag, create_by, create_time, update_by, update_time, state) values @@ -127,32 +129,32 @@ update workflow - - name = #{name}, + + name = #{workflow.name}, - - description = #{description}, + + description = #{workflow.description}, - - dag = #{dag}, + + dag = #{workflow.dag}, - - create_by = #{createBy}, + + create_by = #{workflow.createBy}, - - create_time = #{createTime}, + + create_time = #{workflow.createTime}, - - update_by = #{updateBy}, + + update_by = #{workflow.updateBy}, - - update_time = #{updateTime}, + + update_time = #{workflow.updateTime}, - - state = #{state}, + + state = #{workflow.state} - where id = #{id} + where id = #{workflow.id} @@ -167,8 +169,8 @@ from workflow state = 1 - - and name like "%"#{name}"%" + + and name like "%"#{workflow.name}"%"