Browse Source

description partner

master
Daniel 1 year ago
parent
commit
0d93a0415b
8 changed files with 26 additions and 2 deletions
  1. +2
    -2
      migrations/Version20240327103616.php
  2. +2
    -0
      src/ApiResource/PartnerApi.php
  3. +4
    -0
      src/ApiResource/SaleApi.php
  4. +14
    -0
      src/Entity/Partner.php
  5. +1
    -0
      src/Factory/PartnerFactory.php
  6. +1
    -0
      src/Mapper/PartnerApiToEntityMapper.php
  7. +1
    -0
      src/Mapper/PartnerEntityToApiMapper.php
  8. +1
    -0
      src/Mapper/SaleEntityToApiMapper.php

migrations/Version20240326161210.php → migrations/Version20240327103616.php View File

@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240326161210 extends AbstractMigration
final class Version20240327103616 extends AbstractMigration
{
public function getDescription(): string
{
@@ -25,7 +25,7 @@ final class Version20240326161210 extends AbstractMigration
$this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, partner_id INT DEFAULT NULL, product_id INT DEFAULT NULL, document_object_id INT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D8698A76B03A8386 (created_by_id), INDEX IDX_D8698A769393F8FE (partner_id), INDEX IDX_D8698A764584665A (product_id), INDEX IDX_D8698A7631157E8A (document_object_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE document_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE media_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE partner_follow (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, partner_id INT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_55FFED0BA76ED395 (user_id), INDEX IDX_55FFED0B9393F8FE (partner_id), UNIQUE INDEX unique_follow (user_id, partner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE posting (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, partner_id INT NOT NULL, contact_id INT DEFAULT NULL, sale_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_BD275D737E3C61F9 (owner_id), INDEX IDX_BD275D739393F8FE (partner_id), INDEX IDX_BD275D73E7A1254A (contact_id), INDEX IDX_BD275D734A7E4868 (sale_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, image_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D34A04AD3DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');

+ 2
- 0
src/ApiResource/PartnerApi.php View File

@@ -62,6 +62,8 @@ class PartnerApi
#[NotBlank]
public PartnerType $partnerType;

public ?string $description = null;

public ?string $street = null;

public ?string $streetNo = null;


+ 4
- 0
src/ApiResource/SaleApi.php View File

@@ -13,6 +13,7 @@ use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Sale;
use App\Enum\PartnerType;
use App\Interface\OwnerInterface;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
@@ -61,6 +62,9 @@ class SaleApi implements OwnerInterface
#[ApiProperty(writable: true)]
public ?PartnerApi $partner = null;

#[ApiProperty(writable: false)]
public PartnerType $partnerType;

#[ApiProperty(writable: false)]
public ?string $partnerName = null;



+ 14
- 0
src/Entity/Partner.php View File

@@ -6,6 +6,7 @@ use App\Enum\PartnerType;
use App\Repository\PartnerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: PartnerRepository::class)]
@@ -22,6 +23,9 @@ class Partner
#[ORM\Column(type: 'string', enumType: PartnerType::class)]
private PartnerType $type;

#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;

#[ORM\Column(length: 255, nullable: true)]
private ?string $street = null;

@@ -98,6 +102,16 @@ class Partner
$this->type = $type;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): void
{
$this->description = $description;
}

public function getStreet(): ?string
{
return $this->street;


+ 1
- 0
src/Factory/PartnerFactory.php View File

@@ -52,6 +52,7 @@ final class PartnerFactory extends ModelFactory
return [
'name' => self::faker()->randomElement(FakeValues::COMPANY_NAMES)." ".self::faker()->randomElement(FakeValues::COMPANY_LEGAL_FORMS),
'type' => self::faker()->randomElement(PartnerType::cases()),
'description' => self::faker()->text(),
'street' => self::faker()->randomElement(FakeValues::STREETS),
'streetNo' => self::faker()->numberBetween(1,1000),
'zip' => self::faker()->numberBetween(1000,10000),


+ 1
- 0
src/Mapper/PartnerApiToEntityMapper.php View File

@@ -45,6 +45,7 @@ class PartnerApiToEntityMapper implements MapperInterface
$entity = $to;
assert($entity instanceof Partner);

$entity->setDescription($dto->description);
$entity->setName($dto->name);
$entity->setType($dto->partnerType);
$entity->setStreet($dto->street);


+ 1
- 0
src/Mapper/PartnerEntityToApiMapper.php View File

@@ -43,6 +43,7 @@ class PartnerEntityToApiMapper implements MapperInterface

$dto->name = $entity->getName();
$dto->partnerType = $entity->getType();
$dto->description = $entity->getDescription();
$dto->street = $entity->getStreet();
$dto->streetNo = $entity->getStreetNo();
$dto->zip = $entity->getZip();


+ 1
- 0
src/Mapper/SaleEntityToApiMapper.php View File

@@ -52,6 +52,7 @@ class SaleEntityToApiMapper implements MapperInterface
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();
$dto->partnerType = $entity->getPartner()?->getType();

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,


Loading…
Cancel
Save