feat: ajout de la description et de la date d'ajout dans le endpoint MangaList

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-17 15:15:05 +01:00
parent 140cc14316
commit 7303d63198
4 changed files with 27 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ use App\Domain\Manga\Domain\Model\ValueObject\ImageUrls;
use App\Domain\Manga\Domain\Model\ValueObject\MangaId; use App\Domain\Manga\Domain\Model\ValueObject\MangaId;
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug; use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle; use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle;
use DateTimeImmutable;
final class Manga final class Manga
{ {
@@ -23,6 +24,7 @@ final class Manga
private ?string $imageUrl = null, private ?string $imageUrl = null,
private ?float $rating = null, private ?float $rating = null,
private ?ImageUrls $imageUrls = null, private ?ImageUrls $imageUrls = null,
private ?DateTimeImmutable $createdAt = null,
) {} ) {}
public function getId(): MangaId public function getId(): MangaId
@@ -99,4 +101,9 @@ final class Manga
{ {
$this->imageUrls = $imageUrls; $this->imageUrls = $imageUrls;
} }
public function getCreatedAt(): ?DateTimeImmutable
{
return $this->createdAt;
}
} }

View File

@@ -3,6 +3,7 @@
namespace App\Domain\Manga\Infrastructure\ApiPlatform\Dto; namespace App\Domain\Manga\Infrastructure\ApiPlatform\Dto;
use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiProperty;
use DateTimeImmutable;
readonly class MangaListItem readonly class MangaListItem
{ {
@@ -10,12 +11,14 @@ readonly class MangaListItem
#[ApiProperty(identifier: true)] #[ApiProperty(identifier: true)]
public string $id, public string $id,
public string $title, public string $title,
public string $description,
public string $slug, public string $slug,
public ?string $imageUrl, public ?string $imageUrl,
public string $author, public string $author,
public int $publicationYear, public int $publicationYear,
public array $genres, public array $genres,
public string $status, public string $status,
public ?float $rating public ?float $rating,
public DateTimeImmutable $createdAt,
) {} ) {}
} }

View File

@@ -45,12 +45,14 @@ readonly class GetMangaListStateProvider implements ProviderInterface
id: $manga->getId()->getValue(), id: $manga->getId()->getValue(),
title: $manga->getTitle()->getValue(), title: $manga->getTitle()->getValue(),
slug: $manga->getSlug()->getValue(), slug: $manga->getSlug()->getValue(),
description: $manga->getDescription(),
imageUrl: $manga->getImageUrl(), imageUrl: $manga->getImageUrl(),
author: $manga->getAuthor(), author: $manga->getAuthor(),
publicationYear: $manga->getPublicationYear(), publicationYear: $manga->getPublicationYear(),
genres: $manga->getGenres(), genres: $manga->getGenres(),
status: $manga->getStatus(), status: $manga->getStatus(),
rating: $manga->getRating() rating: $manga->getRating(),
createdAt: $manga->getCreatedAt()
); );
} }
} }

View File

@@ -13,6 +13,7 @@ use Doctrine\ORM\EntityManagerInterface;
use App\Domain\Manga\Domain\Model\Chapter; use App\Domain\Manga\Domain\Model\Chapter;
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId; use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
use App\Entity\Chapter as EntityChapter; use App\Entity\Chapter as EntityChapter;
use DateTime;
readonly class LegacyMangaRepository implements MangaRepositoryInterface readonly class LegacyMangaRepository implements MangaRepositoryInterface
{ {
@@ -165,17 +166,18 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
private function toDomain(EntityManga $entity): DomainManga private function toDomain(EntityManga $entity): DomainManga
{ {
return new DomainManga( return new DomainManga(
new MangaId((string) $entity->getId()), id: new MangaId((string) $entity->getId()),
new MangaTitle($entity->getTitle()), title: new MangaTitle($entity->getTitle()),
new MangaSlug($entity->getSlug()), slug: new MangaSlug($entity->getSlug()),
$entity->getDescription(), description: $entity->getDescription(),
$entity->getAuthor(), author: $entity->getAuthor(),
$entity->getPublicationYear(), publicationYear: $entity->getPublicationYear(),
$entity->getGenres(), genres: $entity->getGenres(),
$entity->getStatus(), status: $entity->getStatus(),
$entity->getExternalId() ? new ExternalId($entity->getExternalId()) : null, externalId: $entity->getExternalId() ? new ExternalId($entity->getExternalId()) : null,
$entity->getImageUrl(), imageUrl: $entity->getImageUrl(),
$entity->getRating() rating: $entity->getRating(),
createdAt: $entity->getCreatedAt(),
); );
} }