From d24619749b7a5a0cb26f4829865eb8532febabec Mon Sep 17 00:00:00 2001 From: fans <1141904845@qq.com> Date: Fri, 5 Jan 2024 10:49:25 +0800 Subject: [PATCH] add controller --- .../component/ComponentController.java | 93 ++++++++++++ .../controller/dataset/DatasetController.java | 115 +++++++++++++++ .../experiment/ExperimentController.java | 134 +++++++++++++++++ .../experiment/ExperimentInsController.java | 120 +++++++++++++++ .../controller/jupyter/JupyterController.java | 43 ++++++ .../controller/model/ModelsController.java | 131 +++++++++++++++++ .../workflow/WorkflowController.java | 138 ++++++++++++++++++ 7 files changed, 774 insertions(+) create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java new file mode 100644 index 00000000..8e9cc051 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java @@ -0,0 +1,93 @@ +package com.ruoyi.platform.controller.component; + +import com.ruoyi.platform.domain.*; +import com.ruoyi.platform.service.*; +import com.ruoyi.platform.vo.ComponentVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * (Component)表控制层 + * + * @author Xidaray + * @since 2023-11-30 11:34:26 + */ +@RestController +@RequestMapping("component") +@Api("组件管理") +public class ComponentController { + /** + * 服务对象 + */ + @Resource + private ComponentService componentService; + + /** + * 分页查询 + * + * @param component 筛选条件 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(Component component, int page, int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.componentService.queryByPage(component, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("根据id查询") + public ResponseEntity queryById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.componentService.queryById(id)); + } + + /** + * 新增数据 + * + * @param component 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("添加组件") + public ResponseEntity add(@RequestBody ComponentVo component) { + return ResponseEntity.ok(this.componentService.insert(component)); + } + + /** + * 编辑数据 + * + * @param component 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑组件") + public ResponseEntity edit(@RequestBody ComponentVo component) { + return ResponseEntity.ok(this.componentService.update(component)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping("{id}") + @ApiOperation("根据id删除组件") + public ResponseEntity deleteById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.componentService.removeById(id)); + } + +} + 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 new file mode 100644 index 00000000..f447a7bd --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java @@ -0,0 +1,115 @@ +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.ApiOperation; +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; + +/** + * (Dataset)表控制层 + * + * @author Xidaray + * @since 2023-11-28 11:46:50 + */ +@RestController +@RequestMapping("dataset") +@Api(value = "数据集管理") +public class DatasetController { + /** + * 服务对象 + */ + @Resource + private DatasetService datasetService; + + /** + * 分页查询 + * + * @param dataset 筛选条件 + * @param page 页数 + * @param size 大小 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(Dataset dataset, int page,int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.datasetService.queryByPage(dataset, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("根据id查询数据集") + public ResponseEntity queryById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.datasetService.queryById(id)); + } + + /** + * 新增数据 + * + * @param dataset 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("添加数据集") + public ResponseEntity add(Dataset dataset) { + return ResponseEntity.ok(this.datasetService.insert(dataset)); + } + + /** + * 编辑数据 + * + * @param dataset 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑数据集") + public ResponseEntity edit(Dataset dataset) { + return ResponseEntity.ok(this.datasetService.update(dataset)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping({"{id}"}) + @ApiOperation("删除数据集") + public ResponseEntity deleteById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.datasetService.removeById(id)); + } + + /** + * 下载数据集 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("/download/{id}") + @ApiOperation("下载数据集") + public ResponseEntity downloadDataset(@PathVariable("id") Integer id) { + return datasetService.downloadDataset(id); + } + + @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)); + + } + +} + diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java new file mode 100644 index 00000000..7f4ce952 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java @@ -0,0 +1,134 @@ +package com.ruoyi.platform.controller.experiment; + + +import com.ruoyi.platform.domain.*; +import com.ruoyi.platform.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * (Experiment)表控制层 + * + * @author makejava + * @since 2023-11-01 16:50:37 + */ +@RestController +@RequestMapping("experiment") +@Api("实验管理") +public class ExperimentController { + /** + * 服务对象 + */ + @Resource + private ExperimentService experimentService; + + /** + * 分页查询 + * + * @param experiment 筛选条件 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(Experiment experiment, int page,int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.experimentService.queryByPage(experiment, pageRequest)); + } + + @GetMapping(("/status")) + @ApiOperation("查询实验状态") + public Page selectStatus(Experiment experiment, PageRequest pageRequest){ + return this.experimentService.selectStatus(experiment, pageRequest); + } + + + + @GetMapping(("/configuration")) + public ResponseEntity showExperimentConfig(Experiment experiment){ + return this.experimentService.showExperimentConfig(experiment); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("通过id查询实验") + public ResponseEntity queryById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.experimentService.queryById(id)); + } + + /** + * 新增数据 + * + * @param experiment 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("新增实验") + public ResponseEntity add(Experiment experiment) { + return ResponseEntity.ok(this.experimentService.insert(experiment)); + } + + /** + * 编辑数据 + * + * @param experiment 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑实验") + public ResponseEntity edit(Experiment experiment) { + return ResponseEntity.ok(this.experimentService.update(experiment)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping("{id}") + @ApiOperation("删除流水线") + public ResponseEntity deleteById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.experimentService.removeById(id)); + } + + + + /** + * 实验管理页面运行实验 + * + * + * + * @param id 主键 + * @return 运行结果 + */ + @PutMapping("/experiments/{id}") + @ApiOperation("运行实验") + public ResponseEntity runExperiment(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.experimentService.runExperiment(id)); + } + + /** + * 实验创建页面确定并运行 + * + * @param experiment 实体 + * @return 运行结果 + */ + @PostMapping("/addAndRunExperiment") + @ApiOperation("实验创建页面确定并运行") + public ResponseEntity addAndRunExperiment(Experiment experiment) { + return ResponseEntity.ok(this.experimentService.addAndRunExperiment(experiment)); + } +} + diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java new file mode 100644 index 00000000..c5dc043a --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java @@ -0,0 +1,120 @@ +package com.ruoyi.platform.controller.experiment; + +import com.ruoyi.platform.domain.ExperimentIns; +import com.ruoyi.platform.service.ExperimentInsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * (ExperimentIns)表控制层 + * + * @author makejava + * @since 2023-11-07 15:08:22 + */ +@RestController +@RequestMapping("experimentIns") +@Api("实验实例管理") +public class ExperimentInsController { + /** + * 服务对象 + */ + @Resource + private ExperimentInsService experimentInsService; + + /** + * 分页查询 + * + * @param experimentIns 筛选条件 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(ExperimentIns experimentIns, int page, int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.experimentInsService.queryByPage(experimentIns, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("通过id查询实验实例") + public ResponseEntity queryById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.experimentInsService.queryById(id)); + } + + + + /** + * 新增数据 + * + * @param experimentIns 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("新增实验实例") + public ResponseEntity add(ExperimentIns experimentIns) { + return ResponseEntity.ok(this.experimentInsService.insert(experimentIns)); + } + + /** + * 编辑数据 + * + * @param experimentIns 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑实验实例") + public ResponseEntity edit(ExperimentIns experimentIns) { + return ResponseEntity.ok(this.experimentInsService.update(experimentIns)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping("{id}") + @ApiOperation("删除实验实例") + public ResponseEntity deleteById( @PathVariable("id") Integer id) { + return ResponseEntity.ok(this.experimentInsService.removeById(id)); + } + + /** + * 终止实验实例 + * + * @param id 主键 + * @return 运行结果 + */ + @PutMapping("{id}") + @ApiOperation("终止实验实例") + public boolean terminateExperimentIns(@PathVariable("id") Integer id) { + return this.experimentInsService.terminateExperimentIns(id); + } + + /** + * 查询实验实例日志 + * + * @param id 主键 + * @return 运行日志 + */ + + @GetMapping(("/log/{id}")) + public String showExperimentInsLog(@PathVariable("id") Integer id){ + return this.experimentInsService.showExperimentInsLog(id); + } + + + +} + diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java new file mode 100644 index 00000000..2d568ff0 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java @@ -0,0 +1,43 @@ +package com.ruoyi.platform.controller.jupyter; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.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; + +import javax.annotation.Resource; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +@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()); + } + + @GetMapping(value = "/upload") + public AjaxResult upload() throws Exception { + File file = new File("D://nexus-deploy.yaml"); + InputStream inputStream = new FileInputStream(file); + jupyterService.upload(inputStream); + return AjaxResult.success(); + } + + @GetMapping(value = "/mlflow") + public AjaxResult mlflow() throws Exception { + jupyterService.mlflow(); + return AjaxResult.success(); + } +} 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 new file mode 100644 index 00000000..79d124c5 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java @@ -0,0 +1,131 @@ +package com.ruoyi.platform.controller.model; + + + +import com.ruoyi.platform.domain.*; +import com.ruoyi.platform.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +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; + +/** + * (Models)表控制层 + * + * @author Xidaray + * @since 2023-11-28 16:21:30 + */ +@RestController +@RequestMapping("models") +@Api("模型管理") +public class ModelsController { + /** + * 服务对象 + */ + @Resource + private ModelsService modelsService; + + /** + * 分页查询 + * + * @param models 筛选条件 + * @param page 分页对象 + * @param size 分页对象 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(Models models, int page, int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.modelsService.queryByPage(models, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("根据id查询") + public ResponseEntity queryById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.modelsService.queryById(id)); + } + + /** + * 新增数据 + * + * @param models 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("添加模型") + public ResponseEntity add(Models models) { + return ResponseEntity.ok(this.modelsService.insert(models)); + } + + /** + * 编辑数据 + * + * @param models 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑模型") + public ResponseEntity edit(Models models) { + return ResponseEntity.ok(this.modelsService.update(models)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping("{id}") + @ApiOperation("删除模型") + public ResponseEntity deleteById(@PathVariable("id") Integer id) { + return ResponseEntity.ok(this.modelsService.removeById(id)); + } + + /** + * 模型上传 + * + * + * + * @param file 文件 + * @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)); + + } + + + /** + * 模型下载 + * + * + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("/download/{id}") + @ApiOperation("下载模型") + public ResponseEntity downloadModels(@PathVariable("id") Integer id) + + { + return modelsService.downloadModels(id); + } + +} + diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java new file mode 100644 index 00000000..325655ff --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java @@ -0,0 +1,138 @@ +package com.ruoyi.platform.controller.workflow; + +import com.ruoyi.platform.domain.Workflow; +import com.ruoyi.platform.service.WorkflowService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * DAG workflow(Workflow)表控制层 + * + * @author makejava + * @since 2023-10-18 14:23:56 + */ +@RestController +@RequestMapping("workflow") +@Api("流水线管理") +public class WorkflowController { + + + + + + /** + * 服务对象 + */ + @Resource + private WorkflowService workflowService; + + /** + * 分页查询 + * + * @param workflow 筛选条件 + * @return 查询结果 + */ + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity> queryByPage(Workflow workflow, int page,int size) { + PageRequest pageRequest = PageRequest.of(page,size); + return ResponseEntity.ok(this.workflowService.queryByPage(workflow, pageRequest)); + } + + + /** + * 按流水线名字模糊查询 + * + * @param name 筛选条件 + * @return 查询结果 + */ + @GetMapping("name/{name}") + @ApiOperation("按流水线名字模糊查询流水线") + public ResponseEntity> queryByName(@PathVariable("name")String name) { + return ResponseEntity.ok(this.workflowService.queryByName(name)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + @ApiOperation("根据id查询单条数据") + public ResponseEntity queryById(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.workflowService.queryById(id)); + } + + /** + * 新增数据 + * + * @param workflow 实体 + * @return 新增结果 + */ + @PostMapping + @ApiOperation("新增") + public ResponseEntity add(Workflow workflow) { + return ResponseEntity.ok(this.workflowService.insert(workflow)); + } + + + /** + * 复制流水线记录重新插入数据库 + * + * @param id 需要复制的流水线id + * @return 复制结果 + */ + @ApiOperation("复制流水线记录") + @PostMapping("duplicate/{id}") + public ResponseEntity duplicateWorkflow(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.workflowService.duplicateWorkflow(id)); + } + + /** + * 流水线编辑页面保存接口 + * + * @return 保存结果 + */ +// @ApiOperation("流水线保存") +// @PutMapping("/saveWorkflow/{id}") +// public ResponseEntity saveWorkflow(@PathVariable("id") Long id) { +// return ResponseEntity.ok(this.workflowService.saveWorkflow(id)); +// } + + + /* + 编辑数据 + + @param workflow 实体 + * @return 编辑结果 + */ + @PutMapping + @ApiOperation("编辑流水线") + public ResponseEntity edit(Workflow workflow) { + return ResponseEntity.ok(this.workflowService.update(workflow)); + } + + /** + * + * + * + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping("{id}") + @ApiOperation("删除流水线") + public ResponseEntity deleteById(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.workflowService.removeById(id)); + } + +} +