feat: ASW-181 playbook 修改接口开发

This commit is contained in:
zhangshuai
2024-11-19 11:34:24 +08:00
parent 9ba7619752
commit ec4c58db4e
3 changed files with 25 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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);
}

View File

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