feat: ASW-181 playbook 修改接口开发
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user