feat : creer une nouvelle expedtion (WIP)

This commit is contained in:
2026-02-10 16:16:05 +01:00
parent 42c5a3b2d2
commit bffdc88701
19 changed files with 1083 additions and 125 deletions

View File

@@ -4,64 +4,64 @@ declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity]
#[ApiFilter(SearchFilter::class, properties: ['shipment' => 'exact'])]
#[ORM\UniqueConstraint(name: 'uniq_bovin_shipment', columns: ['shipment_id', 'shipment_type_id'])]
#[ORM\Table(name: 'bovin_shipment')]
#[ApiResource(
operations: [
new Get(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['bovin-shipment:read']],
normalizationContext: ['groups' => ['shipment-bovine:read']],
),
new GetCollection(
normalizationContext: ['groups' => ['bovin-shipment:read']],
normalizationContext: ['groups' => ['shipment-bovine:read']],
),
// new Get(
// uriTemplate: '/receptions/weigh',
// openapi: new OpenApiOperation(
// summary: 'Fetch the current weight reading',
// description: 'Queries the pont-bascule and returns the weight data.',
// ),
// normalizationContext: ['groups' => ['reception:weigh:read']],
// output: PontBasculeReading::class,
// provider: ReceptionWeighingProvider::class,
// ),
// new Get(
// uriTemplate: '/receptions/{id}/receipt',
// requirements: ['id' => '\d+'],
// openapi: new OpenApiOperation(
// summary: 'Render a reception receipt',
// description: 'Returns a PDF receipt for the reception.',
// ),
// output: false,
// provider: ReceptionReceiptProvider::class,
// ),
new Post(
normalizationContext: ['groups' => ['shipment-bovine:read']],
denormalizationContext: ['groups' => ['shipment-bovine:write']],
),
new Patch(
normalizationContext: ['groups' => ['shipment-bovine:read']],
denormalizationContext: ['groups' => ['shipment-bovine:write']],
),
new Delete(),
],
security: "is_granted('ROLE_USER')",
)]
class BovinShipment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
#[Groups(['shipment:read', 'shipment-bovine:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'shipment_types')]
#[Groups(['bovine-shipment:read'])]
#[ORM\ManyToOne(inversedBy: 'bovinShipments')]
#[Groups(['shipment-bovine:read', 'shipment-bovine:write'])]
#[ApiProperty(readableLink: true)]
private ?Shipment $shipment = null;
#[ORM\ManyToOne]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
#[Groups(['shipment:read', 'shipment-bovine:write', 'shipment-bovine:read'])]
#[ApiProperty(readableLink: true)]
private ?ShipmentType $shipmentType = null;
#[ORM\Column]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
#[Groups(['shipment:read', 'shipment-bovine:write', 'shipment-bovine:read'])]
private ?int $nbBovinSend = null;
public function getId(): ?int