Browse Source

entity changing

Vincent GUFFON 3 năm trước cách đây
mục cha
commit
c3f2b0c911

+ 89 - 0
src/Entity/Message/AbstractMessage.php

@@ -3,13 +3,17 @@ declare(strict_types=1);
 
 namespace App\Entity\Message;
 
+use App\Annotation\OrganizationDefaultValue;
 use App\Entity\Organization\Organization;
+use App\Enum\Message\MessageStatusEnum;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
 
 /**
  * Classe ... qui ...
  */
 #[ORM\MappedSuperclass]
+#[OrganizationDefaultValue(fieldName: "organization")]
 abstract class AbstractMessage
 {
     #[ORM\Id]
@@ -17,12 +21,97 @@ abstract class AbstractMessage
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
+    #[ORM\Column]
+    protected ?string $uniqueSendId = null;
+
     #[ORM\ManyToOne]
     #[ORM\JoinColumn(nullable: true)]
     protected Organization $organization;
 
+    #[ORM\Column(type: 'string', options: ['default' => 'DRAFT'])]
+    #[Assert\Choice(callback: [MessageStatusEnum::class, 'toArray'], message: 'invalid-departure-cause')]
+    protected string $status;
+
+    #[ORM\Column(type: 'datetime', nullable: true)]
+    protected ?\DateTimeInterface $dateSent = null;
+
+    #[ORM\Column(type: 'string', length: 255, nullable: true)]
+    protected string $about;
+
+    #[ORM\Column(type: 'text', nullable: true)]
+    protected string $text;
+
     public function getId(): ?int
     {
         return $this->id;
     }
+
+    public function setUniqueSendId(string $uniqueSendId): self
+    {
+        $this->uniqueSendId = $uniqueSendId;
+        return $this;
+    }
+
+    public function getUniqueSendId(): string
+    {
+        return $this->uniqueSendId;
+    }
+
+    public function setOrganization(Organization $organization): self
+    {
+        $this->organization = $organization;
+        return $this;
+    }
+
+    public function getOrganization(): Organization
+    {
+        return $this->organization;
+    }
+
+    public function setAbout(string $about): self
+    {
+        $this->about = $about;
+        return $this;
+    }
+
+    public function getAbout(): string
+    {
+        return $this->about;
+    }
+
+    public function setText(string $text): self
+    {
+        $this->text = $text;
+        return $this;
+    }
+
+    public function getText(): string
+    {
+        return html_entity_decode($this->text);
+    }
+
+    public function setStatus(string $status)
+    {
+        $this->status = $status;
+
+        return $this;
+    }
+
+    public function getStatus(): string
+    {
+        return $this->status;
+    }
+
+
+    public function setDateSent(\DateTimeInterface $dateSent)
+    {
+        $this->dateSent = $dateSent;
+
+        return $this;
+    }
+
+    public function getDateSent(): ?\DateTimeInterface
+    {
+        return $this->dateSent;
+    }
 }

+ 59 - 1
src/Entity/Message/AbstractReport.php

@@ -3,14 +3,72 @@ declare(strict_types=1);
 
 namespace App\Entity\Message;
 
+use App\Entity\Access\Access;
+use App\Entity\Organization\Organization;
+use App\Enum\Message\ReportMessageSatusEnum;
+use Symfony\Component\Validator\Constraints as Assert;
 use Doctrine\ORM\Mapping as ORM;
 
-
 /**
  * Classe ... qui ...
  */
 #[ORM\MappedSuperclass]
 class AbstractReport
 {
+    #[ORM\Column(type: 'date', nullable: true)]
+    protected ?\DatetimeInterface $dateSend;
+
+    #[ORM\Column(length: 255)]
+    #[Assert\Choice(callback: [ReportMessageSatusEnum::class, 'toArray'], message: 'invalid-report-type')]
+    protected string $status;
+
+    #[ORM\ManyToOne(inversedBy: 'report')]
+    protected ?Access $access;
+
+    #[ORM\ManyToOne(inversedBy: 'report')]
+    protected ?Organization $organization;
+
+    public function getDateSend(): ?\DatetimeInterface
+    {
+        return $this->dateSend;
+    }
+
+    public function setDateSend(?\DatetimeInterface $dateSend): self
+    {
+        $this->dateSend = $dateSend;
+        return $this;
+    }
+
+    public function getStatus(): string
+    {
+        return $this->status;
+    }
+
+    public function setStatus(string $status): self
+    {
+        $this->status = $status;
+        return $this;
+    }
+
+    public function getAccess(): ?Access
+    {
+        return $this->access;
+    }
+
+    public function setAccess(?Access $access): self
+    {
+        $this->access = $access;
+        return $this;
+    }
+
+    public function getOrganization(): ?Organization
+    {
+        return $this->organization;
+    }
 
+    public function setOrganization(?Organization $organization): self
+    {
+        $this->organization = $organization;
+        return $this;
+    }
 }

+ 15 - 0
src/Entity/Message/Email.php

@@ -25,6 +25,9 @@ class Email extends AbstractMessage
     #[ORM\Column(length: 255, nullable: false)]
     private string $discr = 'email';
 
+    #[ORM\Column(type: 'boolean', options: ['default' => false])]
+    private bool $isSystem = false;
+
     #[ORM\ManyToOne(inversedBy: 'emails')]
     #[ORM\JoinColumn(nullable: true)]
     private Access $author;
@@ -67,6 +70,18 @@ class Email extends AbstractMessage
         return $this;
     }
 
+    public function setIsSystem(bool $isSystem): self
+    {
+        $this->isSystem = $isSystem;
+
+        return $this;
+    }
+
+    public function getIsSystem(): bool
+    {
+        return $this->isSystem;
+    }
+
     public function getAuthor(): ?Access
     {
         return $this->author;

+ 29 - 0
src/Entity/Message/ReportEmail.php

@@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
 /**
  * Classe ... qui ...
  */
+#[ORM\Table(name: 'ReportMessage')]
 #[Auditable]
 #[ORM\Entity]
 class ReportEmail extends AbstractReport
@@ -19,8 +20,24 @@ class ReportEmail extends AbstractReport
     private ?int $id = null;
 
     #[ORM\ManyToOne(inversedBy: 'report')]
+    #[ORM\JoinColumn('message_id')]
     private Email $email;
 
+    #[ORM\Column(length: 255)]
+    private string $addressEmail;
+
+    public function getDiscr(): ?string
+    {
+        return $this->discr;
+    }
+
+    public function setDiscr(string $discr): self
+    {
+        $this->discr = $discr;
+
+        return $this;
+    }
+
     public function getId(): ?int
     {
         return $this->id;
@@ -37,4 +54,16 @@ class ReportEmail extends AbstractReport
 
         return $this;
     }
+
+    public function getAddressEmail(): ?string
+    {
+        return $this->addressEmail;
+    }
+
+    public function setAddressEmail(?string $addressEmail): self
+    {
+        $this->addressEmail = $addressEmail;
+
+        return $this;
+    }
 }

+ 23 - 0
src/Entity/Message/ReportSms.php

@@ -5,10 +5,12 @@ namespace App\Entity\Message;
 
 use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Serializer\Annotation\Groups;
 
 /**
  * Classe ... qui ...
  */
+#[ORM\Table(name: 'ReportMessage')]
 #[Auditable]
 #[ORM\Entity]
 class ReportSms extends AbstractReport
@@ -19,8 +21,29 @@ class ReportSms extends AbstractReport
     private ?int $id = null;
 
     #[ORM\ManyToOne(inversedBy: 'report')]
+    #[ORM\JoinColumn('message_id')]
     private Sms $sms;
 
+    #[ORM\Column(length: 255)]
+    private string $mobile;
+
+    #[ORM\Column(type: 'string', nullable: true)]
+    #[Assert\Type(type: 'string')]
+    #[Groups(['reportmessage', 'report'])]
+    private $smsId;
+
+    public function getDiscr(): ?string
+    {
+        return $this->discr;
+    }
+
+    public function setDiscr(string $discr): self
+    {
+        $this->discr = $discr;
+
+        return $this;
+    }
+
     public function getId(): ?int
     {
         return $this->id;

+ 20 - 0
src/Enum/Core/EmailSendingTypeEnum.php

@@ -0,0 +1,20 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Enum\Core;
+
+use MyCLabs\Enum\Enum;
+
+/**
+ * Type de point de contact
+ *
+ * @method static TO()
+ * @method static BBC()
+ * @method static CC()
+ */
+class EmailSendingTypeEnum extends Enum
+{
+    private const TO = 'TO';
+    private const BBC = 'BBC';
+    private const CC = 'CC';
+}

+ 20 - 0
src/Enum/Message/MessageStatusEnum.php

@@ -0,0 +1,20 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Enum\Message;
+
+use MyCLabs\Enum\Enum;
+
+/**
+ * Cycle Enum.
+ */
+class MessageStatusEnum extends Enum
+{
+    private const DRAFT = 'DRAFT';
+    private const CREATING = 'CREATING';
+    private const READY = 'READY';
+    private const SEND = 'SEND';
+    private const PRINTED = 'PRINTED';
+    private const SENDING_IN_PROGRESS = 'SENDING_IN_PROGRESS';
+    private const FAILED = 'FAILED';
+}

+ 37 - 0
src/Enum/Message/ReportMessageSatusEnum.php

@@ -0,0 +1,37 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Enum\Message;
+
+use MyCLabs\Enum\Enum;
+
+/**
+ * Report Mail status.
+ *
+ */
+class ReportMessageSatusEnum extends Enum
+{
+  private const DELIVERED = 'DELIVERED';
+  private const PRINTED = 'PRINTED';
+  private const DELIVERY_IN_PROGRESS = 'DELIVERY_IN_PROGRESS';
+  private const NOT_DELIVERED = 'NOT_DELIVERED';
+  private const INVALID = 'INVALID';
+  private const MISSING = 'MISSING';
+  private const WAITING = "WAITING";
+  private const WAIT4DLVR = "WAITING_DELIVERY";
+  private const SENT = "SENT";
+  private const DLVRD = "DLVRD";
+  private const TOOM4USER = "TOO_MANY_SMS_FROM_USER";
+  private const TOOM4NUM = "TOO_MANY_SMS_FOR_NUMBER";
+  private const ERROR = "ERROR";
+  private const TIMEOUT = "TIMEOUT";
+  private const UNKNRCPT = "UNPARSABLE_RCPT";
+  private const UNKNPFX = "UNKNOWN_PREFIX";
+  private const DEMO = "SENT_IN_DEMO_MODE";
+  private const SCHEDULED = "WAITING_DELAYED";
+  private const INVALIDDST = "INVALID_DESTINATION";
+  private const BLACKLISTED = "NUMBER_BLACKLISTED";
+  private const NUMBER_USER_BLACKLISTED = "BLACKLISTED";
+  private const KO = "SMSC_REJECTED";
+  private const INVALIDCONTENTS = "INVALID_CONTENTS";
+}

+ 17 - 0
src/Enum/Message/SendStatusEnum.php

@@ -0,0 +1,17 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Enum\Message;
+
+use MyCLabs\Enum\Enum;
+
+/**
+ * Cycle Enum.
+ * @method static READY()
+ * @method static FAILED()
+ */
+class SendStatusEnum extends Enum
+{
+    private const FAILED = 'FAILED';
+    private const READY = 'READY';
+}