<?php
declare(strict_types=1);
namespace App\Domain\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Application\ApiResources\State\Processor\TroubleshootingRequestCreateProcessor;
use App\Application\ApiResources\State\Processor\TroubleshootingRequestEditProcessor;
use App\Application\Controller\Api\TroubleshootingRequest\GetAllAction;
use App\Application\Controller\Api\TroubleshootingRequest\GetBanStatusAction;
use App\Application\Controller\Api\TroubleshootingRequest\GetDetailsAction;
use App\Application\Controller\Api\TroubleshootingRequest\GetMineAction;
use App\Domain\Entity\Behavior\Identifiable;
use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
use Gedmo\Timestampable\Traits\Timestampable;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
operations: [
new Delete(security: "is_granted('ROLE_ADMIN')"),
new GetCollection(
controller: GetAllAction::class,
security: "is_granted('ROLE_ADMIN')",
),
new GetCollection(
uriTemplate: '/troubleshooting_requests/ban_status',
controller: GetBanStatusAction::class,
security: "is_granted('ROLE_USER')"
),
new GetCollection(
uriTemplate: '/troubleshooting_requests/mine',
controller: GetMineAction::class,
security: "is_granted('ROLE_USER')"
),
new Get(
uriTemplate: '/troubleshooting_requests/{uuid}',
controller: GetDetailsAction::class,
security: "is_granted('ROLE_ADMIN')",
name: 'get_details'
),
new Post(
processor: TroubleshootingRequestCreateProcessor::class,
),
new Put(
processor: TroubleshootingRequestEditProcessor::class,
),
],
normalizationContext: ['groups' => ['troubleshooting_request_read']],
denormalizationContext: ['groups' => ['troubleshooting_request_write']],
)]
class TroubleshootingRequest
{
use Identifiable;
use SoftDeleteable;
use Timestampable;
public ?\DateTime $zhistUpdate = null;
#[Groups(['troubleshooting_request_read'])]
private Person $person;
#[Groups(['troubleshooting_request_read'])]
private int $status;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
public ?string $result;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
public ?int $review;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
public ?string $comment;
#[Groups(['troubleshooting_request_read'])]
private ?string $jsonAiResponse;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
private ?string $requestText;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
public $uuid;
#[Groups(['troubleshooting_request_read', 'troubleshooting_request_write'])]
public ?string $language;
public function __construct(?string $requestText = null)
{
$this->requestText = $requestText;
}
// Getter and setter methods...
public function getRequestText(): ?string
{
return $this->requestText;
}
public function setRequestText(string $requestText): void
{
$this->requestText = $requestText;
}
public function getPerson(): Person
{
return $this->person;
}
public function setPerson(Person $person): void
{
$this->person = $person;
}
public function getStatus(): int
{
return $this->status;
}
public function setStatus(int $status): void
{
$this->status = $status;
}
public function getResult(): string
{
return $this->result;
}
public function setResult(string $result): void
{
$this->result = $result;
}
public function getReview(): ?int
{
return $this->review;
}
public function setReview(?int $review): void
{
$this->review = $review;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): void
{
$this->comment = $comment;
}
public function getJsonAiResponse(): ?string
{
return $this->jsonAiResponse;
}
public function setJsonAiResponse(?string $jsonAiResponse): void
{
$this->jsonAiResponse = $jsonAiResponse;
}
#[Groups(['troubleshooting_request_read'])]
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
#[Groups(['troubleshooting_request_read'])]
public function getId(): ?int
{
return $this->id;
}
public function getLanguage(): ?string
{
return $this->language;
}
public function setLanguage(?string $language): void
{
$this->language = $language;
}
}