Update Unidades organizativas
parent
e0b19263e7
commit
bb664c52e6
|
@ -105,116 +105,54 @@ properties:
|
|||
|
||||
#### App\Entity\OrganizationalUnit
|
||||
|
||||
- **id**:
|
||||
- **Identifier**: `false`
|
||||
### Fields Required in OrganizationalUnit Endpoint Input
|
||||
|
||||
- **uuid**:
|
||||
- **Identifier**: `true`
|
||||
1. **name**
|
||||
- **Type**: string
|
||||
- **Validation**: Not blank
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
### Organizational Unit Input DTO
|
||||
2. **parent**
|
||||
- **Type**: `OrganizationalUnitOutput`
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
```php
|
||||
<?php
|
||||
3. **description**
|
||||
- **Type**: string
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
namespace App\Dto\Input;
|
||||
4. **location**
|
||||
- **Type**: string
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Validator\Constraints\OrganizationalUnitMulticastMode;
|
||||
use App\Validator\Constraints\OrganizationalUnitMulticastPort;
|
||||
use App\Validator\Constraints\OrganizationalUnitP2PMode;
|
||||
use App\Validator\Constraints\OrganizationalUnitType;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
5. **projector**
|
||||
- **Type**: boolean
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
class OrganizationalUnitInput
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $name = null;
|
||||
6. **board**
|
||||
- **Type**: boolean
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?OrganizationalUnitOutput $parent = null;
|
||||
7. **capacity**
|
||||
- **Type**: integer
|
||||
- **Validation**: Greater than 0
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $description = null;
|
||||
8. **comments**
|
||||
- **Type**: string
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $location = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $projector = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $board = null;
|
||||
|
||||
#[Assert\GreaterThan(0)]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $capacity = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $comments = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
#[OrganizationalUnitType]
|
||||
public ?string $type = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
#[Assert\Valid()]
|
||||
public ?NetworkSettingsInput $networkSettings = null;
|
||||
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
if (!$organizationalUnit) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->name = $organizationalUnit->getName();
|
||||
if ($organizationalUnit->getParent()) {
|
||||
$this->parent = new OrganizationalUnitOutput($organizationalUnit->getParent());
|
||||
}
|
||||
$this->description = $organizationalUnit->getDescription();
|
||||
$this->location = $organizationalUnit->getLocation();
|
||||
$this->projector = $organizationalUnit->isProjector();
|
||||
$this->board = $organizationalUnit->isBoard();
|
||||
$this->capacity = $organizationalUnit->getCapacity();
|
||||
$this->comments = $organizationalUnit->getComments();
|
||||
$this->type = $organizationalUnit->getType();
|
||||
if ($organizationalUnit->getNetworkSettings()) {
|
||||
$this->networkSettings = new NetworkSettingsInput($organizationalUnit->getNetworkSettings());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?OrganizationalUnit $organizationalUnit = null): OrganizationalUnit
|
||||
{
|
||||
if (!$organizationalUnit) {
|
||||
$organizationalUnit = new OrganizationalUnit();
|
||||
}
|
||||
|
||||
$organizationalUnit->setName($this->name);
|
||||
if ($this->parent) {
|
||||
$organizationalUnit->setParent($this->parent->getEntity());
|
||||
}
|
||||
$organizationalUnit->setDescription($this->description);
|
||||
$organizationalUnit->setLocation($this->location);
|
||||
$organizationalUnit->setProjector($this->projector);
|
||||
$organizationalUnit->setBoard($this->board);
|
||||
$organizationalUnit->setCapacity($this->capacity);
|
||||
$organizationalUnit->setComments($this->comments);
|
||||
$organizationalUnit->setType($this->type);
|
||||
|
||||
if ($this->networkSettings) {
|
||||
$organizationalUnit->setNetworkSettings($this->networkSettings->createOrUpdateEntity($organizationalUnit->getNetworkSettings()));
|
||||
}
|
||||
|
||||
return $organizationalUnit;
|
||||
}
|
||||
}
|
||||
```
|
||||
9. **type**
|
||||
- **Type**: string
|
||||
- **Validation**: Custom constraint `OrganizationalUnitType`
|
||||
- **Groups**: `organizational-unit:write`
|
||||
|
||||
10. **networkSettings**
|
||||
- **Type**: `NetworkSettingsInput`
|
||||
- **Validation**: Valid
|
||||
- **Groups**: `organizational-unit:write`
|
||||
---
|
||||
|
||||
|
||||
## Español
|
||||
|
||||
### Tabla de Contenidos
|
||||
|
|
Loading…
Reference in New Issue