From ec4c58db4e888946b94c0f57a06f31c610930dba Mon Sep 17 00:00:00 2001 From: zhangshuai Date: Tue, 19 Nov 2024 11:34:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20ASW-181=20playbook=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runner/controller/PlaybookController.java | 9 +++++++++ .../module/runner/service/IPlaybookService.java | 2 ++ .../runner/service/impl/PlaybookServiceImpl.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/main/java/net/geedge/asw/module/runner/controller/PlaybookController.java b/src/main/java/net/geedge/asw/module/runner/controller/PlaybookController.java index b5c8d2b..918c6e5 100644 --- a/src/main/java/net/geedge/asw/module/runner/controller/PlaybookController.java +++ b/src/main/java/net/geedge/asw/module/runner/controller/PlaybookController.java @@ -46,6 +46,15 @@ public class PlaybookController { return R.ok().put("record", playbook); } + @PutMapping("/{workspaceId}/playbook/{playbookId}") + public R update(@PathVariable("workspaceId") String workspaceId, + @PathVariable("playbookId") String playbookId, + @RequestParam("name") String name, + @RequestParam(value = "description", required = false) String description) { + PlaybookEntity playbook = playbookService.updatePlaybook(workspaceId, playbookId, name, description); + return R.ok().putData("record", playbook); + } + @DeleteMapping("/{workspaceId}/playbook") public R delete(@PathVariable("workspaceId") String workspaceId, @RequestParam("ids") String ids) { diff --git a/src/main/java/net/geedge/asw/module/runner/service/IPlaybookService.java b/src/main/java/net/geedge/asw/module/runner/service/IPlaybookService.java index c6d4dcd..7177cea 100644 --- a/src/main/java/net/geedge/asw/module/runner/service/IPlaybookService.java +++ b/src/main/java/net/geedge/asw/module/runner/service/IPlaybookService.java @@ -16,4 +16,6 @@ public interface IPlaybookService extends IService{ PlaybookEntity savePlaybook(String workspaceId, MultipartFile file, String name, String type, String description); void delete(String workspaceId, String ids); + + PlaybookEntity updatePlaybook(String workspaceId, String playbookId, String name, String description); } diff --git a/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java b/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java index 70aae10..7c02ce7 100644 --- a/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java @@ -110,4 +110,18 @@ public class PlaybookServiceImpl extends ServiceImpl().eq(PlaybookEntity::getWorkspaceId, workspaceId).eq(PlaybookEntity::getName, name)); + if (T.ObjectUtil.isNotEmpty(playbook) && !playbookId.equals(playbook.getId())) { + throw new ASWException(RCode.PLAYBOOK_NAME_DUPLICATE); + } + PlaybookEntity playbookEntity = this.getById(playbookId); + playbookEntity.setName(name); + playbookEntity.setDescription(description); + this.updateById(playbookEntity); + return playbookEntity; + } }