Phase 0 : entités, migrations, API Platform, PostGIS
- API Platform + Doctrine ORM + jsor/doctrine-postgis installés - 6 entités Symfony (SargassumObservation, SargassumForecast, DataIngestionJob, CoastalPoint, ImpactScore, UserFeedback) - Migration initiale manuelle avec CREATE EXTENSION postgis, toutes les tables, index GIST et BTREE - doctrine.yaml configuré pour PostgreSQL 16 + types PostGIS - Roadmap Phase 0 complète Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
71
backend/src/Entity/CoastalPoint.php
Normal file
71
backend/src/Entity/CoastalPoint.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\CoastalPointRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CoastalPointRepository::class)]
|
||||
#[ORM\Index(columns: ['type'], name: 'idx_coastal_type')]
|
||||
#[ORM\Index(columns: ['region'], name: 'idx_coastal_region')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(),
|
||||
new Get(),
|
||||
]
|
||||
)]
|
||||
class CoastalPoint
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 150)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(type: 'geometry', options: ['geometry_type' => 'POINT', 'srid' => 4326])]
|
||||
private mixed $geometry = null;
|
||||
|
||||
#[ORM\Column(length: 30)]
|
||||
private ?string $type = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
private ?string $region = null;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: ImpactScore::class, mappedBy: 'coastalPoint')]
|
||||
private Collection $impactScores;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: UserFeedback::class, mappedBy: 'coastalPoint')]
|
||||
private Collection $feedbacks;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->impactScores = new ArrayCollection();
|
||||
$this->feedbacks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid { return $this->id; }
|
||||
public function getName(): ?string { return $this->name; }
|
||||
public function setName(string $name): static { $this->name = $name; return $this; }
|
||||
public function getGeometry(): mixed { return $this->geometry; }
|
||||
public function setGeometry(mixed $geometry): static { $this->geometry = $geometry; return $this; }
|
||||
public function getType(): ?string { return $this->type; }
|
||||
public function setType(string $type): static { $this->type = $type; return $this; }
|
||||
public function getRegion(): ?string { return $this->region; }
|
||||
public function setRegion(string $region): static { $this->region = $region; return $this; }
|
||||
|
||||
/** @return Collection<int, ImpactScore> */
|
||||
public function getImpactScores(): Collection { return $this->impactScores; }
|
||||
|
||||
/** @return Collection<int, UserFeedback> */
|
||||
public function getFeedbacks(): Collection { return $this->feedbacks; }
|
||||
}
|
||||
Reference in New Issue
Block a user