add set deletion

This commit is contained in:
Yisroel Baum 2026-07-02 17:13:11 +03:00
parent ae48bdf93b
commit fb88bbfaa9
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 147 additions and 0 deletions

View file

@ -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,