feat: Reader beginning

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-16 16:15:42 +01:00
parent e90c0a140e
commit 55945adc53
37 changed files with 1057 additions and 47 deletions

View File

@@ -21,15 +21,15 @@ use Symfony\Component\Validator\Constraints as Assert;
readonly class ScrapeChapterRequest
{
public function __construct(
#[ApiProperty(description: 'ID du chapitre à scraper')]
#[Assert\NotBlank]
public string $chapterId,
#[ApiProperty(description: 'ID de la source à utiliser')]
#[Assert\NotBlank]
public string $sourceId,
#[ApiProperty(description: 'ID du manga')]
#[Assert\NotBlank]
public string $mangaId,
#[ApiProperty(description: 'Numéro du chapitre')]
#[Assert\NotBlank]
public string $chapterNumber,
#[ApiProperty(description: 'ID de la source')]
#[Assert\NotBlank]
public string $sourceId,
) {
}
}

View File

@@ -22,9 +22,9 @@ final class ScrapeChapterStateProcessor implements ProcessorInterface
{
$this->commandBus->dispatch(
new ScrapeChapter(
$data->chapterId,
$data->sourceId,
$data->mangaId
$data->mangaId,
$data->chapterNumber,
$data->sourceId
)
);
}

View File

@@ -7,12 +7,15 @@ use App\Domain\Scraping\Domain\Exception\ChapterNotFoundException;
use App\Domain\Scraping\Domain\Model\Chapter;
use App\Entity\Chapter as EntityChapter;
use Doctrine\ORM\EntityManagerInterface;
class LegacyChapterRepository implements ChapterRepositoryInterface
readonly class LegacyChapterRepository implements ChapterRepositoryInterface
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private EntityManagerInterface $entityManager,
) {}
/**
* @throws ChapterNotFoundException
*/
public function getByMangaIdAndChapterNumber(string $mangaId, int $chapterNumber): Chapter
{
$chapterEntity = $this->entityManager->getRepository(EntityChapter::class)->findOneBy([
@@ -31,4 +34,23 @@ class LegacyChapterRepository implements ChapterRepositoryInterface
volumeNumber: $chapterEntity->getVolume(),
);
}
/**
* @throws ChapterNotFoundException
*/
public function save(Chapter $chapter): void
{
$chapterEntity = $this->entityManager->getRepository(EntityChapter::class)->findOneBy([
'id' => $chapter->id,
]);
if (!$chapterEntity) {
throw new ChapterNotFoundException();
}
$chapterEntity->setCbzPath($chapter->cbzPath);
$this->entityManager->persist($chapterEntity);
$this->entityManager->flush();
}
}