feat: GetMangaList endpoint + tests + test db
This commit is contained in:
parent
073439163b
commit
e3d380eadd
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Manga\Application\QueryHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Query\GetMangaList;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Application\Response\MangaListResponse;
|
||||
|
||||
readonly class GetMangaListHandler
|
||||
{
|
||||
public function __construct(
|
||||
private MangaRepositoryInterface $mangaRepository
|
||||
) {}
|
||||
|
||||
public function handle(GetMangaList $query): MangaListResponse
|
||||
{
|
||||
$mangas = $this->mangaRepository->findAll(
|
||||
page: $query->page,
|
||||
limit: $query->limit,
|
||||
sortBy: $query->sortBy,
|
||||
sortOrder: $query->sortOrder
|
||||
);
|
||||
|
||||
$total = $this->mangaRepository->count();
|
||||
|
||||
return new MangaListResponse(
|
||||
mangas: $mangas,
|
||||
total: $total,
|
||||
page: $query->page,
|
||||
limit: $query->limit
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user