浏览代码

description partner

master
Daniel 1年前
父节点
当前提交
0d93a0415b
共有 8 个文件被更改,包括 26 次插入2 次删除
  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 查看文件

@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/** /**
* Auto-generated Migration: Please modify to your needs! * Auto-generated Migration: Please modify to your needs!
*/ */
final class Version20240326161210 extends AbstractMigration
final class Version20240327103616 extends AbstractMigration
{ {
public function getDescription(): string 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 (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 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 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 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 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'); $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 查看文件

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


public ?string $description = null;

public ?string $street = null; public ?string $street = null;


public ?string $streetNo = null; public ?string $streetNo = null;


+ 4
- 0
src/ApiResource/SaleApi.php 查看文件

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


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

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




+ 14
- 0
src/Entity/Partner.php 查看文件

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


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


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

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


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


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

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

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


+ 1
- 0
src/Factory/PartnerFactory.php 查看文件

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


+ 1
- 0
src/Mapper/PartnerApiToEntityMapper.php 查看文件

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


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


+ 1
- 0
src/Mapper/PartnerEntityToApiMapper.php 查看文件

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


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


+ 1
- 0
src/Mapper/SaleEntityToApiMapper.php 查看文件

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


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


正在加载...
取消
保存