Added missing lastModified and creationDate fields to API response

This commit is contained in:
Jan Böhmer 2023-10-04 00:08:10 +02:00
parent e09f60e71f
commit 64c38042a0
9 changed files with 56 additions and 4 deletions

View file

@ -156,6 +156,12 @@ abstract class Attachment extends AbstractNamedDBElement
#[Groups(['attachment:read', 'attachment_write'])] #[Groups(['attachment:read', 'attachment_write'])]
protected ?AttachmentType $attachment_type = null; protected ?AttachmentType $attachment_type = null;
#[Groups(['attachment:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['attachment:read'])]
protected ?\DateTimeInterface $lastModified = null;
public function __construct() public function __construct()
{ {
//parent::__construct(); //parent::__construct();

View file

@ -76,7 +76,7 @@ use Symfony\Component\Validator\Constraints as Assert;
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: AttachmentType::class) 'id' => new Link(fromProperty: 'children', fromClass: AttachmentType::class)
], ],
normalizationContext: ['groups' => ['footprint:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] normalizationContext: ['groups' => ['attachment_type:read', 'api:basic:read'], 'openapi_definition_name' => 'Read']
)] )]
#[ApiFilter(PropertyFilter::class)] #[ApiFilter(PropertyFilter::class)]
#[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])]
@ -96,7 +96,7 @@ class AttachmentType extends AbstractStructuralDBElement
/** /**
* @var string A comma separated list of file types, which are allowed for attachment files. * @var string A comma separated list of file types, which are allowed for attachment files.
* Must be in the format of <input type=file> accept attribute * Must be in the format of <pre><input type=file></pre> accept attribute
* (See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers). * (See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers).
*/ */
#[ORM\Column(type: Types::TEXT)] #[ORM\Column(type: Types::TEXT)]
@ -132,6 +132,12 @@ class AttachmentType extends AbstractStructuralDBElement
#[ORM\OneToMany(targetEntity: Attachment::class, mappedBy: 'attachment_type')] #[ORM\OneToMany(targetEntity: Attachment::class, mappedBy: 'attachment_type')]
protected Collection $attachments_with_type; protected Collection $attachments_with_type;
#[Groups(['attachment_type:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['attachment_type:read'])]
protected ?\DateTimeInterface $lastModified = null;
public function __construct() public function __construct()
{ {
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();

View file

@ -177,6 +177,12 @@ class Category extends AbstractPartsContainingDBElement
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters; protected Collection $parameters;
#[Groups(['category:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['category:read'])]
protected ?\DateTimeInterface $lastModified = null;
public function getPartnameHint(): string public function getPartnameHint(): string
{ {
return $this->partname_hint; return $this->partname_hint;

View file

@ -129,6 +129,12 @@ class Footprint extends AbstractPartsContainingDBElement
#[Groups(['footprint:read', 'footprint:write'])] #[Groups(['footprint:read', 'footprint:write'])]
protected Collection $parameters; protected Collection $parameters;
#[Groups(['footprint:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['footprint:read'])]
protected ?\DateTimeInterface $lastModified = null;
/**************************************** /****************************************
* Getters * Getters
****************************************/ ****************************************/

View file

@ -150,6 +150,12 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
#[Groups(['measurement_unit:read', 'measurement_unit:write'])] #[Groups(['measurement_unit:read', 'measurement_unit:write'])]
protected Collection $parameters; protected Collection $parameters;
#[Groups(['measurement_unit:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['measurement_unit:read'])]
protected ?\DateTimeInterface $lastModified = null;
/** /**
* @return string * @return string
*/ */

View file

@ -150,6 +150,12 @@ class Part extends AttachmentContainingDBElement
#[Groups(['part:read', 'part:write'])] #[Groups(['part:read', 'part:write'])]
protected ?Attachment $master_picture_attachment = null; protected ?Attachment $master_picture_attachment = null;
#[Groups(['part:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['part:read'])]
protected ?\DateTimeInterface $lastModified = null;
public function __construct() public function __construct()
{ {
$this->attachments = new ArrayCollection(); $this->attachments = new ArrayCollection();

View file

@ -164,6 +164,12 @@ class StorageLocation extends AbstractPartsContainingDBElement
#[Groups(['location:read', 'location:write'])] #[Groups(['location:read', 'location:write'])]
protected ?Attachment $master_picture_attachment = null; protected ?Attachment $master_picture_attachment = null;
#[Groups(['location:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['location:read'])]
protected ?\DateTimeInterface $lastModified = null;
/******************************************************************************** /********************************************************************************
* *
* Getters * Getters

View file

@ -36,8 +36,6 @@ use ApiPlatform\Metadata\Post;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentTypeAttachment;
use App\Entity\Parts\Footprint;
use App\Repository\CurrencyRepository; use App\Repository\CurrencyRepository;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use App\Entity\Attachments\CurrencyAttachment; use App\Entity\Attachments\CurrencyAttachment;
@ -152,6 +150,12 @@ class Currency extends AbstractStructuralDBElement
#[ORM\OneToMany(targetEntity: Pricedetail::class, mappedBy: 'currency')] #[ORM\OneToMany(targetEntity: Pricedetail::class, mappedBy: 'currency')]
protected Collection $pricedetails; protected Collection $pricedetails;
#[Groups(['currency:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['currency:read'])]
protected ?\DateTimeInterface $lastModified = null;
public function __construct() public function __construct()
{ {
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();

View file

@ -153,6 +153,12 @@ class Project extends AbstractStructuralDBElement
#[Groups(['project:read', 'project:write'])] #[Groups(['project:read', 'project:write'])]
protected Collection $parameters; protected Collection $parameters;
#[Groups(['project:read'])]
protected ?\DateTimeInterface $addedDate = null;
#[Groups(['project:read'])]
protected ?\DateTimeInterface $lastModified = null;
/******************************************************************************** /********************************************************************************
* *
* Getters * Getters