mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add POST watchlist endpoint
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use App\Repository\WatchListRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -13,15 +16,26 @@ use Symfony\Component\Uid\Uuid;
|
||||
#[ORM\Entity(repositoryClass: WatchListRepository::class)]
|
||||
#[ApiResource(
|
||||
shortName: 'Watchlist',
|
||||
normalizationContext: ['groups' => 'watchlist:item', 'domain:list'],
|
||||
denormalizationContext: ['groups' => 'watchlist:item', 'domain:list'],
|
||||
paginationEnabled: false
|
||||
operations: [
|
||||
new GetCollection(
|
||||
routeName: 'watchlist_get_all_mine', normalizationContext: ['groups' => 'watchlist:list'],
|
||||
name: 'get_all_mine',
|
||||
),
|
||||
new Get(
|
||||
normalizationContext: ['groups' => 'watchlist:item']
|
||||
),
|
||||
new Post(
|
||||
routeName: 'watchlist_create', normalizationContext: ['groups' => 'watchlist:list'],
|
||||
denormalizationContext: ['groups' => 'watchlist:create'],
|
||||
name: 'create'
|
||||
)
|
||||
],
|
||||
)]
|
||||
class WatchList
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(length: 36)]
|
||||
#[Groups(['watchlist:item'])]
|
||||
#[Groups(['watchlist:item', 'watchlist:list'])]
|
||||
private string $token;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchLists')]
|
||||
@@ -35,7 +49,7 @@ class WatchList
|
||||
#[ORM\JoinTable(name: 'watch_lists_domains',
|
||||
joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')],
|
||||
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')])]
|
||||
#[Groups(['watchlist:item'])]
|
||||
#[Groups(['watchlist:item', 'watchlist:create'])]
|
||||
private Collection $domains;
|
||||
|
||||
public function __construct()
|
||||
|
||||
Reference in New Issue
Block a user