Add entities (WIP)
This commit is contained in:
parent
f48c80af1c
commit
21b3a72c30
@ -1,6 +1,7 @@
|
|||||||
api_platform:
|
api_platform:
|
||||||
title: Architetture Roma - API
|
title: Architetture Roma - API
|
||||||
version: beta
|
version: beta
|
||||||
|
show_webby: false
|
||||||
defaults:
|
defaults:
|
||||||
stateless: true
|
stateless: true
|
||||||
cache_headers:
|
cache_headers:
|
||||||
|
91
src/Entity/Degradation.php
Normal file
91
src/Entity/Degradation.php
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
|
use App\Repository\DegradationRepository;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: DegradationRepository::class)]
|
||||||
|
#[ORM\Table(name: 'degrado')]
|
||||||
|
#[ApiResource(
|
||||||
|
operations: [
|
||||||
|
new Get(normalizationContext: ['groups' => 'degradation:item']),
|
||||||
|
new GetCollection(normalizationContext: ['groups' => 'degradation:list'])
|
||||||
|
],
|
||||||
|
order: ['term' => 'DESC'],
|
||||||
|
paginationEnabled: false,
|
||||||
|
)]
|
||||||
|
class Degradation
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
#[Groups(['degradation:list', 'degradation:item'])]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 50, name: 'lemma')]
|
||||||
|
#[Groups(['degradation:list', 'degradation:item'])]
|
||||||
|
private ?string $term = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 50, nullable: true, name: 'classe')]
|
||||||
|
#[Groups(['degradation:list', 'degradation:item'])]
|
||||||
|
private ?string $class = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::BIGINT, nullable: true, name: 'materiale')]
|
||||||
|
//#[ORM\ManyToOne()]
|
||||||
|
#[Groups(['degradation:list', 'degradation:item'])]
|
||||||
|
private ?string $material = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $id): static
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTerm(): ?string
|
||||||
|
{
|
||||||
|
return $this->term;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTerm(string $term): static
|
||||||
|
{
|
||||||
|
$this->term = $term;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClass(): ?string
|
||||||
|
{
|
||||||
|
return $this->class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setClass(?string $class): static
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaterial(): ?string
|
||||||
|
{
|
||||||
|
return $this->material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMaterial(?string $material): static
|
||||||
|
{
|
||||||
|
$this->material = $material;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
42
src/Entity/Material.php
Normal file
42
src/Entity/Material.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\MaterialRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: MaterialRepository::class)]
|
||||||
|
class Material
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 50)]
|
||||||
|
private ?string $term = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $id): static
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTerm(): ?string
|
||||||
|
{
|
||||||
|
return $this->term;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTerm(string $term): static
|
||||||
|
{
|
||||||
|
$this->term = $term;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
43
src/Repository/DegradationRepository.php
Normal file
43
src/Repository/DegradationRepository.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Degradation;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Degradation>
|
||||||
|
*/
|
||||||
|
class DegradationRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Degradation::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Degradation[] Returns an array of Degradation objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('d')
|
||||||
|
// ->andWhere('d.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('d.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Degradation
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('d')
|
||||||
|
// ->andWhere('d.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
43
src/Repository/MaterialRepository.php
Normal file
43
src/Repository/MaterialRepository.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Material;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Material>
|
||||||
|
*/
|
||||||
|
class MaterialRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Material::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Material[] Returns an array of Material objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('m')
|
||||||
|
// ->andWhere('m.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('m.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Material
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('m')
|
||||||
|
// ->andWhere('m.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user