Add Element entity + API for Material
This commit is contained in:
parent
21b3a72c30
commit
32ad965139
184
src/Entity/Element.php
Normal file
184
src/Entity/Element.php
Normal file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\ElementRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ElementRepository::class)]
|
||||
#[ORM\Table(name: 'elemento')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => 'element:item']),
|
||||
new GetCollection(normalizationContext: ['groups' => 'element:list'])
|
||||
],
|
||||
order: ['label' => 'DESC'],
|
||||
paginationEnabled: false,
|
||||
)]
|
||||
class Element
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(name: 'etichetta', length: 6)]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?string $label = null;
|
||||
|
||||
#[ORM\Column(name: 'rango', length: 50, nullable: true)]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?string $rank = null;
|
||||
|
||||
#[ORM\Column(name: 'tipo', type: Types::BIGINT, nullable: true)]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?string $type = null;
|
||||
|
||||
#[ORM\Column(name: 'materiale', type: Types::BIGINT, nullable: true)]
|
||||
#[ORM\ManyToOne(targetEntity: Material::class)]
|
||||
#[JoinColumn(name: 'materiale', referencedColumnName: 'id')]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?string $material = null;
|
||||
|
||||
#[ORM\Column(name: 'lavorazione', type: Types::BIGINT, nullable: true)]
|
||||
private ?string $production = null;
|
||||
|
||||
#[ORM\Column(name: 'posa', type: Types::BIGINT, nullable: true)]
|
||||
private ?string $placement = null;
|
||||
|
||||
#[ORM\Column(name: 'strutt_oriz', type: Types::BIGINT)]
|
||||
private ?string $horizontalStructure = null;
|
||||
|
||||
#[ORM\Column(name: 'riconoscimento', type: Types::BIGINT, nullable: true)]
|
||||
private ?string $identification = null;
|
||||
|
||||
#[ORM\Column(name: 'note', type: Types::TEXT, nullable: true)]
|
||||
#[Groups(['element:list', 'element:item'])]
|
||||
private ?string $notes = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(string $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): static
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRank(): ?string
|
||||
{
|
||||
return $this->rank;
|
||||
}
|
||||
|
||||
public function setRank(?string $rank): static
|
||||
{
|
||||
$this->rank = $rank;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaterial(): ?string
|
||||
{
|
||||
return $this->material;
|
||||
}
|
||||
|
||||
public function setMaterial(?string $material): static
|
||||
{
|
||||
$this->material = $material;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProduction(): ?string
|
||||
{
|
||||
return $this->production;
|
||||
}
|
||||
|
||||
public function setProduction(?string $production): static
|
||||
{
|
||||
$this->production = $production;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlacement(): ?string
|
||||
{
|
||||
return $this->placement;
|
||||
}
|
||||
|
||||
public function setPlacement(?string $placement): static
|
||||
{
|
||||
$this->placement = $placement;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHorizontalStructure(): ?string
|
||||
{
|
||||
return $this->horizontalStructure;
|
||||
}
|
||||
|
||||
public function setHorizontalStructure(string $horizontalStructure): static
|
||||
{
|
||||
$this->horizontalStructure = $horizontalStructure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdentification(): ?string
|
||||
{
|
||||
return $this->identification;
|
||||
}
|
||||
|
||||
public function setIdentification(?string $identification): static
|
||||
{
|
||||
$this->identification = $identification;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNotes(): ?string
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
public function setNotes(?string $notes): static
|
||||
{
|
||||
$this->notes = $notes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -2,18 +2,33 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\MaterialRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MaterialRepository::class)]
|
||||
#[ORM\Table(name: 'voc_materiale')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => 'material:item']),
|
||||
new GetCollection(normalizationContext: ['groups' => 'material:list'])
|
||||
],
|
||||
order: ['term' => 'DESC'],
|
||||
paginationEnabled: false,
|
||||
)]
|
||||
class Material
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['material:list', 'material:item'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
#[ORM\Column(name: 'lemma', length: 50)]
|
||||
#[Groups(['material:list', 'material:item'])]
|
||||
private ?string $term = null;
|
||||
|
||||
public function getId(): ?int
|
||||
|
43
src/Repository/ElementRepository.php
Normal file
43
src/Repository/ElementRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Element;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Element>
|
||||
*/
|
||||
class ElementRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Element::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Element[] Returns an array of Element objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('e.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Element
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user