add set deletion
This commit is contained in:
parent
ae48bdf93b
commit
fb88bbfaa9
4 changed files with 147 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ use App\Set\Set as DomainSet;
|
|||
use App\Set\SetRepository;
|
||||
use App\Set\UseCases\CreateSetWithRoot\CreateSetWithRoot;
|
||||
use App\Set\UseCases\CreateSetWithRoot\CreateSetWithRootRequest;
|
||||
use App\Set\UseCases\DeleteSet\DeleteSet;
|
||||
use App\Set\UseCases\DeleteSet\DeleteSetRequest;
|
||||
use App\Set\UseCases\UpdateSet\UpdateSet;
|
||||
use App\Set\UseCases\UpdateSet\UpdateSetRequest;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
|
@ -23,6 +25,7 @@ class SetController
|
|||
private ElementRepository $elementRepository,
|
||||
private CreateSetWithRoot $createSetWithRoot,
|
||||
private UpdateSet $updateSet,
|
||||
private DeleteSet $deleteSet,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
|
@ -96,6 +99,23 @@ class SetController
|
|||
], 200);
|
||||
}
|
||||
|
||||
public function delete(?int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->deleteSet->execute(new DeleteSetRequest(id: $id));
|
||||
} catch (BadRequestException $exception) {
|
||||
return new JsonResponse([
|
||||
'error' => $exception->getMessage(),
|
||||
], 400);
|
||||
} catch (NotFoundException $exception) {
|
||||
return new JsonResponse([
|
||||
'error' => $exception->getMessage(),
|
||||
], 404);
|
||||
}
|
||||
|
||||
return new JsonResponse(null, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* id: int,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue