feat: ajout de la gestion des sources préférées pour les mangas, incluant la récupération et la configuration des sources via l'API, ainsi que l'intégration d'une modale pour l'interface utilisateur.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-20 15:33:54 +02:00
parent 15d92d1aff
commit 75f8e1686c
22 changed files with 1168 additions and 41 deletions

View File

@@ -0,0 +1,81 @@
<?php
namespace App\Domain\Scraping\Infrastructure\ApiPlatform\Resource;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
use ApiPlatform\OpenApi\Model\Response;
use App\Domain\Scraping\Infrastructure\ApiPlatform\Dto\MangaPreferredSourcesDetail;
use App\Domain\Scraping\Infrastructure\ApiPlatform\State\Provider\GetMangaPreferredSourcesStateProvider;
#[ApiResource(
shortName: 'Scraping',
operations: [
new Get(
uriTemplate: '/mangas/{id}/preferred-sources',
provider: GetMangaPreferredSourcesStateProvider::class,
output: MangaPreferredSourcesDetail::class,
description: 'Récupérer les sources préférées d\'un manga ou toutes les sources si aucune préférence',
openapi: new OpenApiOperation(
summary: 'Récupérer les sources préférées d\'un manga',
description: 'Retourne les sources préférées configurées pour un manga, ou toutes les sources disponibles si aucune préférence définie',
responses: [
'200' => new Response(
description: 'Sources récupérées avec succès',
content: new \ArrayObject([
'application/json' => [
'schema' => [
'type' => 'object',
'properties' => [
'mangaId' => ['type' => 'string'],
'hasPreferredSources' => ['type' => 'boolean'],
'sources' => [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'id' => ['type' => 'string'],
'name' => ['type' => 'string'],
'baseUrl' => ['type' => 'string'],
'description' => ['type' => 'string'],
'isActive' => ['type' => 'boolean']
]
]
]
]
],
'example' => [
'mangaId' => '1',
'hasPreferredSources' => true,
'sources' => [
[
'id' => '1',
'name' => 'MangaDex',
'baseUrl' => 'https://mangadex.org',
'description' => 'Source principale',
'isActive' => true
],
[
'id' => '2',
'name' => 'MangaKakalot',
'baseUrl' => 'https://mangakakalot.com',
'description' => 'Source secondaire',
'isActive' => true
]
]
]
]
])
)
]
)
)
]
)]
class GetMangaPreferredSourcesResource
{
public function __construct(
public string $id
) {}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Domain\Scraping\Infrastructure\ApiPlatform\Resource;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
use ApiPlatform\OpenApi\Model\RequestBody;
use App\Domain\Scraping\Infrastructure\ApiPlatform\State\Processor\SetMangaPreferredSourcesStateProcessor;
use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource(
shortName: 'Scraping',
operations: [
new Post(
uriTemplate: '/mangas/{id}/preferred-sources',
processor: SetMangaPreferredSourcesStateProcessor::class,
status: 200,
description: 'Définir les sources préférées d\'un manga dans l\'ordre de priorité',
openapi: new OpenApiOperation(
summary: 'Configurer les sources préférées d\'un manga',
description: 'Définit l\'ordre de priorité des sources de scraping pour un manga. Format attendu: {"sourceIds": ["source1", "source2"]}',
requestBody: new RequestBody(
content: new \ArrayObject([
'application/json' => [
'schema' => [
'type' => 'object',
'properties' => [
'sourceIds' => [
'type' => 'array',
'items' => ['type' => 'string']
]
]
],
'example' => [
'sourceIds' => ['1', '2']
]
]
])
)
)
)
]
)]
class SetMangaPreferredSourcesResource
{
public function __construct(
#[Assert\NotNull]
#[Assert\All([
new Assert\Type('string')
])]
public array $sourceIds = []
) {}
}