src/Containers/ServiceSection/DataScienceContainer/Entities/DataOperationalResultsEntity.php line 58

Open in your IDE?
  1. <?php
  2. namespace App\Containers\ServiceSection\DataScienceContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. // use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. // use ApiPlatform\Metadata\Patch;
  8. // use ApiPlatform\Metadata\Put;
  9. // use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  15. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  16. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Doctrine\DBAL\Types\Types;
  19. use Gedmo\Mapping\Annotation as Gedmo;
  20. use Symfony\Component\Serializer\Annotation\Groups;
  21. // use Symfony\Component\Serializer\Annotation\MaxDepth;
  22. use Symfony\Component\Serializer\Annotation\Context;
  23. use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
  24. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  25. use App\Containers\ServiceSection\DataScienceContainer\Data\Repositories\DataOperationalResultsRepository;
  26. #[ApiResource(
  27.     routePrefix'/data',
  28.     normalizationContext: [
  29.         'groups' => 'read',
  30.         'enable_max_depth' => true
  31.     ],
  32.     operations: [
  33.         new Get(
  34.             uriTemplate'/data_operational_results/{id}'requirements: ['id' => '\d+']
  35.         ),
  36.         new GetCollection(
  37.             uriTemplate'/data_operational_results'
  38.         )
  39.     ],
  40.     shortName'Service_DataScience',
  41.     security"is_granted('ROLE_ADMIN')"
  42. )]
  43. #[ApiFilter(SearchFilter::class, properties: [
  44.     'id' => 'exact'
  45.     'name' => 'partial'
  46. ])]
  47. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  48. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  49. #[ApiFilter(DateFilter::class, properties: ['dateStart''dateEnd''createdAt''updatedAt'])]
  50. #[ApiFilter(BooleanFilter::class, properties: ['isHide'])]
  51. #[ApiFilter(OrderFilter::class)]
  52. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['name'])]
  53. #[ORM\Entity(repositoryClassDataOperationalResultsRepository::class)]
  54. #[ORM\Table(name'`service_data_science_operational_results`')]
  55. class DataOperationalResultsEntity
  56. {   
  57.     #[ORM\Id]
  58.     #[ORM\GeneratedValue]
  59.     #[ORM\Column(typeTypes::INTEGER)]
  60.     #[Groups(['read'])]
  61.     private ?int $id null;
  62.     // Название
  63.     #[ORM\Column(typeTypes::STRINGlength50nullablefalse)]
  64.     #[Groups(['read'])]
  65.     private string $name;
  66.     // Дата начала периода
  67.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullablefalse)]
  68.     #[Context(
  69.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
  70.         denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  71.     )]
  72.     #[Groups(['read'])]
  73.     private \DateTimeInterface $dateStart;
  74.     // Дата окончания периода
  75.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullablefalse)]
  76.     #[Context(
  77.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
  78.         denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  79.     )]
  80.     #[Groups(['read'])]
  81.     private \DateTimeInterface $dateEnd;
  82.     // Действующие договора
  83.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  84.     #[Groups(['read'])]
  85.     private ?int $currentContractsCount 0;
  86.     // Оплачено грн по действующим договорам
  87.     #[ORM\Column(typeTypes::FLOATscale4options: ['default' => 0.0000])]
  88.     #[Groups(['read'])]
  89.     private ?float $currentContractsPaymentUAH 0.0000;
  90.     // Оплачено км по действующим договорам
  91.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  92.     #[Groups(['read'])]
  93.     private ?int $currentContractsPaymentMileage 0;
  94.     // Активные договора
  95.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  96.     #[Groups(['read'])]
  97.     private ?int $activeContractsCount 0;
  98.     // Оплачено грн по активным договорам
  99.     #[ORM\Column(typeTypes::FLOATscale4options: ['default' => 0.0000])]
  100.     #[Groups(['read'])]
  101.     private ?float $activeContractsPaymentUAH 0.0000;
  102.     // Оплачено км по активным договорам
  103.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  104.     #[Groups(['read'])]
  105.     private ?int $activeContractsPaymentMileage 0;
  106.     #[ORM\Column(typeTypes::BOOLEAN)]
  107.     #[Groups(['read'])]
  108.     private ?bool $isHide false;
  109.     #[Gedmo\Timestampable(on'create')]
  110.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  111.     #[Context(
  112.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  113.     )]
  114.     #[Groups(['read'])]
  115.     protected $createdAt;
  116.     #[Gedmo\Timestampable(on'update')]
  117.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  118.     #[Context(
  119.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  120.     )]
  121.     #[Groups(['read'])]
  122.     protected $updatedAt;
  123.     public function getId(): ?int
  124.     {
  125.         return $this->id;
  126.     }
  127.     public function setName(?string $name): ?self
  128.     {
  129.         $this->name $name;
  130.         return $this;
  131.     }
  132.     public function getName(): ?string
  133.     {
  134.         return $this->name;
  135.     }
  136.     public function setDateStart(?\DateTimeImmutable $date): ?self
  137.     {
  138.         $this->dateStart $date;
  139.         return $this;
  140.     }
  141.     public function getDateStart(): ?\DateTimeInterface
  142.     {
  143.         return $this->dateStart;
  144.     }
  145.     public function setDateEnd(?\DateTimeImmutable $date): ?self
  146.     {
  147.         $this->dateEnd $date;
  148.         return $this;
  149.     }
  150.     public function getDateEnd(): ?\DateTimeInterface
  151.     {
  152.         return $this->dateEnd;
  153.     }
  154.     public function getCurrentContractsCount(): ?int
  155.     {
  156.         return $this->currentContractsCount;
  157.     }
  158.     public function setCurrentContractsCount(?int $value): ?self
  159.     {
  160.         $this->currentContractsCount $value;
  161.         return $this;
  162.     }
  163.     public function getCurrentContractsPaymentUAH(): ?float
  164.     {
  165.         return $this->currentContractsPaymentUAH;
  166.     }
  167.     public function setCurrentContractsPaymentUAH(?float $value): ?self
  168.     {
  169.         $this->currentContractsPaymentUAH = ($value round($value4) : null);
  170.         return $this;
  171.     }
  172.     public function getCurrentContractsPaymentMileage(): ?int
  173.     {
  174.         return $this->currentContractsPaymentMileage;
  175.     }
  176.     public function setCurrentContractsPaymentMileage(?int $value): ?self
  177.     {
  178.         $this->currentContractsPaymentMileage $value;
  179.         return $this;
  180.     }
  181.     public function getActiveContractsCount(): ?int
  182.     {
  183.         return $this->activeContractsCount;
  184.     }
  185.     public function setActiveContractsCount(?int $value): ?self
  186.     {
  187.         $this->activeContractsCount $value;
  188.         return $this;
  189.     }
  190.     public function getActiveContractsPaymentUAH(): ?float
  191.     {
  192.         return $this->activeContractsPaymentUAH;
  193.     }
  194.     public function setActiveContractsPaymentUAH(?float $value): ?self
  195.     {
  196.         $this->activeContractsPaymentUAH = ($value round($value4) : null);
  197.         return $this;
  198.     }
  199.     public function getActiveContractsPaymentMileage(): ?int
  200.     {
  201.         return $this->activeContractsPaymentMileage;
  202.     }
  203.     public function setActiveContractsPaymentMileage(?int $value): ?self
  204.     {
  205.         $this->activeContractsPaymentMileage $value;
  206.         return $this;
  207.     }
  208.     public function getIsHide(): ?bool
  209.     {
  210.         return $this->isHide;
  211.     }
  212.  
  213.     public function setIsHide(?bool $value): ?self
  214.     {
  215.         $this->isHide $value;
  216.         return $this;
  217.     }
  218.     public function getCreatedAt(): ?\DateTimeInterface
  219.     {
  220.         return $this->createdAt;
  221.     }
  222.     public function getUpdatedAt(): ?\DateTimeInterface
  223.     {
  224.         return $this->updatedAt;
  225.     }
  226. }