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; + } }