Commit 97ab1ecb authored by Nikita Chernykh's avatar Nikita Chernykh
Browse files

Merge branch 'STA-1046' into 'main'

Sta 1046

See merge request !18
parents f1f9481f 408cf9da
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.2",
        "php": ">=8.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/dbal": "^3",
@@ -13,6 +13,7 @@
        "doctrine/orm": "^3.1",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.28",
        "ramsey/uuid": "^4.7",
        "ramsey/collection": "^2.0",
        "symfony/asset": "6.4.*",
        "symfony/asset-mapper": "6.4.*",
+25 −4
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20240427114630 extends AbstractMigration
final class Version20240520053704 extends AbstractMigration
{
    public function getDescription(): string
    {
@@ -20,9 +20,12 @@ final class Version20240427114630 extends AbstractMigration
    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE file (id UUID NOT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, size INT NOT NULL, type VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE kitchens (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id UUID DEFAULT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, sort INT NOT NULL, active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, preview_image VARCHAR(255) DEFAULT NULL, preview_text VARCHAR(1000) DEFAULT NULL, detail_image VARCHAR(255) DEFAULT NULL, detail_text VARCHAR(255) DEFAULT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id UUID DEFAULT NULL, detail_image_id UUID DEFAULT NULL, preview_image_id UUID DEFAULT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, sort INT NOT NULL, active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, preview_text VARCHAR(1000) DEFAULT NULL, detail_text VARCHAR(255) DEFAULT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_1DD39950C54C8C93 ON news (type_id)');
        $this->addSql('CREATE INDEX IDX_1DD39950CB7BCCB6 ON news (detail_image_id)');
        $this->addSql('CREATE INDEX IDX_1DD39950FAE957CD ON news (preview_image_id)');
        $this->addSql('COMMENT ON COLUMN news.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN news.update_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE news_news_categories (news_id UUID NOT NULL, news_categories_id UUID NOT NULL, PRIMARY KEY(news_id, news_categories_id))');
@@ -31,15 +34,19 @@ final class Version20240427114630 extends AbstractMigration
        $this->addSql('CREATE TABLE news_categories (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE news_type (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE restaurant_types (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE restaurants (id UUID NOT NULL, type_id UUID DEFAULT NULL, settlement_id UUID DEFAULT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, receipt VARCHAR(255) NOT NULL, receipt_info VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, tags VARCHAR(255) NOT NULL, site VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, gallery VARCHAR(255) NOT NULL, how_to_find VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE restaurants (id UUID NOT NULL, type_id UUID DEFAULT NULL, settlement_id UUID DEFAULT NULL, preview_image_id UUID DEFAULT NULL, detail_image_id UUID DEFAULT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, receipt VARCHAR(255) NOT NULL, receipt_info VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, tags VARCHAR(255) NOT NULL, site VARCHAR(255) NOT NULL, coordinates VARCHAR(1000) NOT NULL, how_to_find VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_AD837724C54C8C93 ON restaurants (type_id)');
        $this->addSql('CREATE INDEX IDX_AD837724C2B9C425 ON restaurants (settlement_id)');
        $this->addSql('CREATE INDEX IDX_AD837724FAE957CD ON restaurants (preview_image_id)');
        $this->addSql('CREATE INDEX IDX_AD837724CB7BCCB6 ON restaurants (detail_image_id)');
        $this->addSql('COMMENT ON COLUMN restaurants.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN restaurants.update_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN restaurants.coordinates IS \'(DC2Type:array)\'');
        $this->addSql('CREATE TABLE restaurants_kitchens (restaurants_id UUID NOT NULL, kitchens_id UUID NOT NULL, PRIMARY KEY(restaurants_id, kitchens_id))');
        $this->addSql('CREATE INDEX IDX_716464694DCA160A ON restaurants_kitchens (restaurants_id)');
        $this->addSql('CREATE INDEX IDX_71646469E043FCBC ON restaurants_kitchens (kitchens_id)');
        $this->addSql('CREATE TABLE restaurants_file (restaurants_id UUID NOT NULL, file_id UUID NOT NULL, PRIMARY KEY(restaurants_id, file_id))');
        $this->addSql('CREATE INDEX IDX_EBC930974DCA160A ON restaurants_file (restaurants_id)');
        $this->addSql('CREATE INDEX IDX_EBC9309793CB796C ON restaurants_file (file_id)');
        $this->addSql('CREATE TABLE settlements (id UUID NOT NULL, active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('COMMENT ON COLUMN settlements.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN settlements.update_at IS \'(DC2Type:datetime_immutable)\'');
@@ -62,12 +69,18 @@ final class Version20240427114630 extends AbstractMigration
        $this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
        $this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
        $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD39950C54C8C93 FOREIGN KEY (type_id) REFERENCES news_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD39950CB7BCCB6 FOREIGN KEY (detail_image_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD39950FAE957CD FOREIGN KEY (preview_image_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news_news_categories ADD CONSTRAINT FK_34AB0102B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news_news_categories ADD CONSTRAINT FK_34AB0102F7F178F1 FOREIGN KEY (news_categories_id) REFERENCES news_categories (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724C54C8C93 FOREIGN KEY (type_id) REFERENCES restaurant_types (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724C2B9C425 FOREIGN KEY (settlement_id) REFERENCES settlements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724FAE957CD FOREIGN KEY (preview_image_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724CB7BCCB6 FOREIGN KEY (detail_image_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_kitchens ADD CONSTRAINT FK_716464694DCA160A FOREIGN KEY (restaurants_id) REFERENCES restaurants (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_kitchens ADD CONSTRAINT FK_71646469E043FCBC FOREIGN KEY (kitchens_id) REFERENCES kitchens (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_file ADD CONSTRAINT FK_EBC930974DCA160A FOREIGN KEY (restaurants_id) REFERENCES restaurants (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_file ADD CONSTRAINT FK_EBC9309793CB796C FOREIGN KEY (file_id) REFERENCES file (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
@@ -75,12 +88,19 @@ final class Version20240427114630 extends AbstractMigration
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950C54C8C93');
        $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950CB7BCCB6');
        $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950FAE957CD');
        $this->addSql('ALTER TABLE news_news_categories DROP CONSTRAINT FK_34AB0102B5A459A0');
        $this->addSql('ALTER TABLE news_news_categories DROP CONSTRAINT FK_34AB0102F7F178F1');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724C54C8C93');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724C2B9C425');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724FAE957CD');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724CB7BCCB6');
        $this->addSql('ALTER TABLE restaurants_kitchens DROP CONSTRAINT FK_716464694DCA160A');
        $this->addSql('ALTER TABLE restaurants_kitchens DROP CONSTRAINT FK_71646469E043FCBC');
        $this->addSql('ALTER TABLE restaurants_file DROP CONSTRAINT FK_EBC930974DCA160A');
        $this->addSql('ALTER TABLE restaurants_file DROP CONSTRAINT FK_EBC9309793CB796C');
        $this->addSql('DROP TABLE file');
        $this->addSql('DROP TABLE kitchens');
        $this->addSql('DROP TABLE news');
        $this->addSql('DROP TABLE news_news_categories');
@@ -89,6 +109,7 @@ final class Version20240427114630 extends AbstractMigration
        $this->addSql('DROP TABLE restaurant_types');
        $this->addSql('DROP TABLE restaurants');
        $this->addSql('DROP TABLE restaurants_kitchens');
        $this->addSql('DROP TABLE restaurants_file');
        $this->addSql('DROP TABLE settlements');
        $this->addSql('DROP TABLE users');
        $this->addSql('DROP TABLE messenger_messages');
+42 −6
Original line number Diff line number Diff line
@@ -2,14 +2,22 @@

namespace App\News\Controller;

use App\News\Request\NewsCreateRequest;
use App\News\Request\NewsDetailRequest;
use App\News\Request\NewsFullUpdateRequest;
use App\News\Request\NewsListingRequest;
use App\News\Request\NewsPartUpdateRequest;
use App\News\UseCase\NewsCreateUseCase;
use App\News\UseCase\NewsDeleteUseCase;
use App\News\UseCase\NewsFullUpdateUseCase;
use App\News\UseCase\NewsGetDetailMainUseCase;
use App\News\UseCase\NewsGetDetailUseCase;
use App\News\UseCase\NewsGetListingUseUseCase;
use App\News\UseCase\NewsGetMainUseCase;
use App\News\UseCase\NewsPartUpdateUseCase;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

#[Route('/api/v1/news')]
@@ -17,9 +25,13 @@ class NewsController extends AbstractController
{
    public function __construct(
        private readonly NewsGetListingUseUseCase $getListingUseCase,
        private readonly NewsGetDetailUseCase $getDetailNews,
        private readonly NewsGetMainUseCase $getMainNews,
        private readonly NewsGetDetailMainUseCase $getDetailMainNews,
        private readonly NewsGetDetailUseCase $getDetailUseCase,
        private readonly NewsGetMainUseCase $getMainUseCase,
        private readonly NewsGetDetailMainUseCase $getDetailMainUseCase,
        private readonly NewsCreateUseCase $createUseCase,
        private readonly NewsFullUpdateUseCase $fullUpdateUseCase,
        private readonly NewsPartUpdateUseCase $partUpdateUseCase,
        private readonly NewsDeleteUseCase $deleteUseCase,
    ) {
    }

@@ -32,18 +44,42 @@ class NewsController extends AbstractController
    #[Route('/mainNews', name: 'mainNews', methods: ['GET'])]
    public function mainNews(): JsonResponse
    {
        return $this->getMainNews->execute();
        return $this->getMainUseCase->execute();
    }

    #[Route('/search', name: 'searchNews', methods: ['GET'])]
    public function detailMainNews(): JsonResponse
    {
        return $this->getDetailMainNews->execute();
        return $this->getDetailMainUseCase->execute();
    }

    #[Route('/{detailId}', name: 'oneNews', methods: ['GET'])]
    public function oneNews(NewsDetailRequest $request): JsonResponse
    {
        return $this->getDetailNews->execute($request);
        return $this->getDetailUseCase->execute($request);
    }

    #[Route('/create', name: 'createNews', methods: ['POST'])]
    public function createNews(NewsCreateRequest $request): Response
    {
        return $this->createUseCase->execute($request);
    }

    #[Route('/update', name: 'updateNews', methods: ['PUT'])]
    public function fillUpdateNews(NewsFullUpdateRequest $request): Response
    {
        return $this->fullUpdateUseCase->execute($request);
    }

    #[Route('/partUpdate', name: 'partUpdateNews', methods: ['PATCH'])]
    public function partUpdateNews(NewsPartUpdateRequest $request): Response
    {
        return $this->partUpdateUseCase->execute($request);
    }

    #[Route('/delete/{detailId}', name: 'deleteNews', methods: ['DELETE'])]
    public function deleteNews(NewsDetailRequest $request): Response
    {
        return $this->deleteUseCase->execute($request);
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -2,19 +2,19 @@

namespace App\News\Dto;

use App\Shared\Collection\ListingCollection;
use App\News\DtoCollection\NewsListingElementCollection;
use App\Shared\Dto\PaginationDto;

class NewsListDto
{
    /**
     * @param PaginationDto $pagination
     * @param ListingCollection<NewsListingElementDto> $list
     * @param NewsListingElementCollection<NewsListingElementDto> $list
     * @param NewsFilterVariantsDto $filterVariants
     */
    public function __construct(
        public PaginationDto $pagination,
        public ListingCollection $list,
        public NewsListingElementCollection $list,
        public NewsFilterVariantsDto $filterVariants,
    ) {
    }
+16 −0
Original line number Diff line number Diff line
<?php

namespace App\News\DtoCollection;

use App\News\Dto\NewsListingElementDto;
use App\Shared\Collection\DtoCollection;

class NewsListingElementCollection extends DtoCollection
{
    private string $collectionType = NewsListingElementDto::class;

    public function __construct(array $data = [])
    {
        parent::__construct($this->collectionType, $data);
    }
}
 No newline at end of file
Loading