fix(backend) : add validation constraints and fix concurrent numbering
- Add Assert\Choice on ClientTicket type and status with typed constants - Add Assert\Url on GiteaConfiguration, BookStackConfiguration, TaskBookStackLink, ClientTicket - Fix concurrent task/ticket numbering: use pg_advisory_xact_lock instead of FOR UPDATE with MAX() - Wrap CreateTaskTool numbering in transaction - Harmonize repository contracts: both return max number, caller adds +1 Tickets: T-004, T-008, T-011, T-012 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
@@ -54,6 +55,27 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
)]
|
||||
class ClientTicket
|
||||
{
|
||||
public const string TYPE_BUG = 'bug';
|
||||
public const string TYPE_IMPROVEMENT = 'improvement';
|
||||
public const string TYPE_OTHER = 'other';
|
||||
|
||||
public const array TYPES = [
|
||||
self::TYPE_BUG,
|
||||
self::TYPE_IMPROVEMENT,
|
||||
self::TYPE_OTHER,
|
||||
];
|
||||
|
||||
public const string STATUS_NEW = 'new';
|
||||
public const string STATUS_IN_PROGRESS = 'in_progress';
|
||||
public const string STATUS_DONE = 'done';
|
||||
public const string STATUS_REJECTED = 'rejected';
|
||||
|
||||
public const array STATUSES = [
|
||||
self::STATUS_NEW,
|
||||
self::STATUS_IN_PROGRESS,
|
||||
self::STATUS_DONE,
|
||||
self::STATUS_REJECTED,
|
||||
];
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
@@ -66,6 +88,7 @@ class ClientTicket
|
||||
|
||||
#[ORM\Column(length: 20)]
|
||||
#[Groups(['client_ticket:read', 'client_ticket:write', 'task:read'])]
|
||||
#[Assert\Choice(choices: self::TYPES)]
|
||||
private ?string $type = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
@@ -78,10 +101,12 @@ class ClientTicket
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['client_ticket:read', 'client_ticket:write'])]
|
||||
#[Assert\Url]
|
||||
private ?string $url = null;
|
||||
|
||||
#[ORM\Column(length: 20)]
|
||||
#[Groups(['client_ticket:read', 'client_ticket:write', 'task:read'])]
|
||||
#[Assert\Choice(choices: self::STATUSES)]
|
||||
private ?string $status = 'new';
|
||||
|
||||
#[ORM\Column(type: 'text', nullable: true)]
|
||||
|
||||
Reference in New Issue
Block a user