From 73a747845e8c5fe11cd7f5b80a918bdced1c8cf0 Mon Sep 17 00:00:00 2001 From: fans <1141904845@qq.com> Date: Thu, 25 Jan 2024 16:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9workflow=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=8Ccopy=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=8A=A0-copy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/workflow/WorkflowController.java | 2 +- .../com/ruoyi/platform/service/WorkflowService.java | 2 +- .../platform/service/impl/WorkflowServiceImpl.java | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) 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 index 4a4bb1e3..816247eb 100644 --- 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 @@ -129,7 +129,7 @@ public class WorkflowController { */ @DeleteMapping("{id}") @ApiOperation("删除流水线") - public AjaxResult deleteById(@PathVariable("id") Long id) { + public AjaxResult deleteById(@PathVariable("id") Long id) throws Exception { return AjaxResult.success(this.workflowService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java index be6461c4..7520c562 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java @@ -52,7 +52,7 @@ public interface WorkflowService { * @return 是否成功 */ boolean deleteById(Long id); - String removeById(Long id); + String removeById(Long id) throws Exception; /** * 按流水线名字模糊分页查询 * diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index 97f36d87..3b1be04c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -107,7 +107,7 @@ public class WorkflowServiceImpl implements WorkflowService { return this.workflowDao.deleteById(id) > 0; } @Override - public String removeById(Long id) { + public String removeById(Long id) throws Exception { //先根据id提取出对应的流水线 Workflow workflow = workflowDao.queryById(id); @@ -116,16 +116,16 @@ public class WorkflowServiceImpl implements WorkflowService { String username = loginUser.getUsername(); String createdBy = workflow.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该流水线"; + throw new Exception("无权限删除该流水线"); } if (workflow == null){ - return "流水线不存在"; + throw new Exception("流水线不存在"); } //判断这个流水线是否有相关实验存在 List experimentList = experimentService.queryByWorkflowId(id); if (experimentList!=null&&experimentList.size()>0){ - return "该流水线存在实验,无法删除"; + throw new Exception("该流水线存在实验,无法删除"); } workflow.setState(0); return this.workflowDao.update(workflow)>0?"删除成功":"删除失败"; @@ -143,7 +143,7 @@ public class WorkflowServiceImpl implements WorkflowService { Workflow workflow = this.queryById(id); if (workflow!= null) { Workflow duplicateWorkflow = new Workflow(); - duplicateWorkflow.setName(workflow.getName()); + duplicateWorkflow.setName(workflow.getName()+"-copy"); duplicateWorkflow.setDag(workflow.getDag()); duplicateWorkflow.setDescription(workflow.getDescription()); return this.insert(duplicateWorkflow);