summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangshuai <[email protected]>2024-11-19 11:34:24 +0800
committerzhangshuai <[email protected]>2024-11-19 11:34:24 +0800
commitec4c58db4e888946b94c0f57a06f31c610930dba (patch)
tree27dcac295c4029e05ac8fd37e2dfd0183fd5aae1
parent9ba7619752697239ebcec92ba118d321ef3e4366 (diff)
feat: ASW-181 playbook 修改接口开发
-rw-r--r--src/main/java/net/geedge/asw/module/runner/controller/PlaybookController.java9
-rw-r--r--src/main/java/net/geedge/asw/module/runner/service/IPlaybookService.java2
-rw-r--r--src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java14
3 files changed, 25 insertions, 0 deletions
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>{
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<PlaybookDao, PlaybookEntity
this.removeById(id);
}
}
+
+ @Override
+ public PlaybookEntity updatePlaybook(String workspaceId, String playbookId, String name, String description) {
+
+ PlaybookEntity playbook = this.baseMapper.selectOne(new LambdaQueryWrapper<PlaybookEntity>().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;
+ }
}