- 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>
73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use App\Repository\ImpactScoreRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
#[ORM\Entity(repositoryClass: ImpactScoreRepository::class)]
|
|
#[ORM\Index(columns: ['timestamp'], name: 'idx_score_timestamp')]
|
|
#[ORM\Index(columns: ['level'], name: 'idx_score_level')]
|
|
#[ApiResource(
|
|
operations: [
|
|
new GetCollection(),
|
|
new Get(),
|
|
]
|
|
)]
|
|
class ImpactScore
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
|
private ?Uuid $id = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'impactScores')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?CoastalPoint $coastalPoint = null;
|
|
|
|
#[ORM\Column]
|
|
private ?\DateTimeImmutable $timestamp = null;
|
|
|
|
#[ORM\Column]
|
|
private ?int $score = null;
|
|
|
|
#[ORM\Column(length: 20)]
|
|
private ?string $level = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?float $distanceToNearestSargassum = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?float $densityEstimate = null;
|
|
|
|
#[ORM\Column(length: 20, nullable: true)]
|
|
private ?string $trend = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->timestamp = new \DateTimeImmutable();
|
|
}
|
|
|
|
public function getId(): ?Uuid { return $this->id; }
|
|
public function getCoastalPoint(): ?CoastalPoint { return $this->coastalPoint; }
|
|
public function setCoastalPoint(?CoastalPoint $coastalPoint): static { $this->coastalPoint = $coastalPoint; return $this; }
|
|
public function getTimestamp(): ?\DateTimeImmutable { return $this->timestamp; }
|
|
public function setTimestamp(\DateTimeImmutable $timestamp): static { $this->timestamp = $timestamp; return $this; }
|
|
public function getScore(): ?int { return $this->score; }
|
|
public function setScore(int $score): static { $this->score = $score; return $this; }
|
|
public function getLevel(): ?string { return $this->level; }
|
|
public function setLevel(string $level): static { $this->level = $level; return $this; }
|
|
public function getDistanceToNearestSargassum(): ?float { return $this->distanceToNearestSargassum; }
|
|
public function setDistanceToNearestSargassum(?float $d): static { $this->distanceToNearestSargassum = $d; return $this; }
|
|
public function getDensityEstimate(): ?float { return $this->densityEstimate; }
|
|
public function setDensityEstimate(?float $d): static { $this->densityEstimate = $d; return $this; }
|
|
public function getTrend(): ?string { return $this->trend; }
|
|
public function setTrend(?string $trend): static { $this->trend = $trend; return $this; }
|
|
}
|