From fcef8fb71b2bb85d8d896d23ecc467dbf8d891b1 Mon Sep 17 00:00:00 2001
From: "a.shamavov" <a.shamavov@iqdev.digital>
Date: Wed, 24 Apr 2024 14:03:13 +0500
Subject: [PATCH] =?UTF-8?q?STA-966=20|=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?=
 =?UTF-8?q?=D0=B8=D0=BB=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9?=
 =?UTF-8?q?=D1=81=D1=8B=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BE?=
 =?UTF-8?q?=D1=80=D0=B8=D0=B5=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 config/packages/nelmio_api_doc.yaml           |   9 ++
 config/routes/nelmio_api_doc.yaml             |  12 ++
 migrations/Version20240424072545.php          | 148 ++++++++++++++++++
 src/Controller/RestaurantController.php       |  38 +++++
 src/Mapper/RestaurantMapper.php               |  55 +++++++
 .../Interface/KitchenRepositoryInterface.php  |   8 +
 .../RestaurantRepositoryInterface.php         |   8 +
 .../RestaurantTypeRepositoryInterface.php     |   8 +
 src/Service/RestaurantService.php             |  58 +++++++
 9 files changed, 344 insertions(+)
 create mode 100644 config/packages/nelmio_api_doc.yaml
 create mode 100644 config/routes/nelmio_api_doc.yaml
 create mode 100644 migrations/Version20240424072545.php
 create mode 100644 src/Controller/RestaurantController.php
 create mode 100644 src/Mapper/RestaurantMapper.php
 create mode 100644 src/Repository/Interface/KitchenRepositoryInterface.php
 create mode 100644 src/Repository/Interface/RestaurantRepositoryInterface.php
 create mode 100644 src/Repository/Interface/RestaurantTypeRepositoryInterface.php
 create mode 100644 src/Service/RestaurantService.php

diff --git a/config/packages/nelmio_api_doc.yaml b/config/packages/nelmio_api_doc.yaml
new file mode 100644
index 0000000..e5eb778
--- /dev/null
+++ b/config/packages/nelmio_api_doc.yaml
@@ -0,0 +1,9 @@
+nelmio_api_doc:
+    documentation:
+        info:
+            title: Yamal
+            description:
+            version: 1.0.0
+    areas: # to filter documented areas
+        path_patterns:
+            - ^/api/v1 # Accepts routes under /api except /api/doc
diff --git a/config/routes/nelmio_api_doc.yaml b/config/routes/nelmio_api_doc.yaml
new file mode 100644
index 0000000..f350dd6
--- /dev/null
+++ b/config/routes/nelmio_api_doc.yaml
@@ -0,0 +1,12 @@
+# Expose your documentation as JSON swagger compliant
+app.swagger:
+    path: /api/doc.json
+    methods: GET
+    defaults: { _controller: nelmio_api_doc.controller.swagger }
+
+## Requires the Asset component and the Twig bundle
+## $ composer require twig asset
+app.swagger_ui:
+    path: /api/doc
+    methods: GET
+    defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
diff --git a/migrations/Version20240424072545.php b/migrations/Version20240424072545.php
new file mode 100644
index 0000000..b77fac7
--- /dev/null
+++ b/migrations/Version20240424072545.php
@@ -0,0 +1,148 @@
+<?php
+
+declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20240424072545 extends AbstractMigration
+{
+    public function getDescription(): string
+    {
+        return '';
+    }
+
+    public function up(Schema $schema): void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->addSql('CREATE SEQUENCE address_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE email_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE kitchen_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE news_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE news_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE phone_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE restaurant_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE restaurant_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE settlement_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE tags_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
+        $this->addSql('CREATE TABLE address (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_D4E6F81B1E7706E ON address (restaurant_id)');
+        $this->addSql('CREATE TABLE email (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_E7927C74B1E7706E ON email (restaurant_id)');
+        $this->addSql('CREATE TABLE kitchen (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_EAA3CE34B1E7706E ON kitchen (restaurant_id)');
+        $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id INT NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, sort INT NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, preview_text TEXT NOT NULL, detail_text TEXT NOT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_1DD39950C54C8C93 ON news (type_id)');
+        $this->addSql('COMMENT ON COLUMN news.id IS \'(DC2Type:uuid)\'');
+        $this->addSql('CREATE TABLE news_news_category (news_id UUID NOT NULL, news_category_id UUID NOT NULL, PRIMARY KEY(news_id, news_category_id))');
+        $this->addSql('CREATE INDEX IDX_1A91D6D6B5A459A0 ON news_news_category (news_id)');
+        $this->addSql('CREATE INDEX IDX_1A91D6D63B732BAD ON news_news_category (news_category_id)');
+        $this->addSql('COMMENT ON COLUMN news_news_category.news_id IS \'(DC2Type:uuid)\'');
+        $this->addSql('COMMENT ON COLUMN news_news_category.news_category_id IS \'(DC2Type:uuid)\'');
+        $this->addSql('CREATE TABLE news_category (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('COMMENT ON COLUMN news_category.id IS \'(DC2Type:uuid)\'');
+        $this->addSql('CREATE TABLE news_comment (id INT NOT NULL, news_id_id UUID NOT NULL, moderator_id_id INT NOT NULL, user_id_id INT NOT NULL, moderated BOOLEAN NOT NULL, user_name VARCHAR(255) NOT NULL, text VARCHAR(255) NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE UNIQUE INDEX UNIQ_C3904E8A5FB1909 ON news_comment (news_id_id)');
+        $this->addSql('CREATE INDEX IDX_C3904E8ACEB712DF ON news_comment (moderator_id_id)');
+        $this->addSql('CREATE INDEX IDX_C3904E8A9D86650F ON news_comment (user_id_id)');
+        $this->addSql('COMMENT ON COLUMN news_comment.news_id_id IS \'(DC2Type:uuid)\'');
+        $this->addSql('CREATE TABLE news_type (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE TABLE phone (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_444F97DDB1E7706E ON phone (restaurant_id)');
+        $this->addSql('CREATE TABLE restaurant (id INT NOT NULL, type_id_id INT NOT NULL, settlement_id_id INT NOT NULL, uuid UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, coordinates TEXT NOT NULL, description TEXT NOT NULL, check_price VARCHAR(255) NOT NULL, check_info TEXT NOT NULL, site VARCHAR(255) NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, how_to_find TEXT NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE UNIQUE INDEX UNIQ_EB95123FD17F50A6 ON restaurant (uuid)');
+        $this->addSql('CREATE INDEX IDX_EB95123F714819A0 ON restaurant (type_id_id)');
+        $this->addSql('CREATE INDEX IDX_EB95123F45EC589B ON restaurant (settlement_id_id)');
+        $this->addSql('COMMENT ON COLUMN restaurant.uuid IS \'(DC2Type:uuid)\'');
+        $this->addSql('COMMENT ON COLUMN restaurant.coordinates IS \'(DC2Type:array)\'');
+        $this->addSql('CREATE TABLE restaurant_type (id INT NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE TABLE settlement (id INT NOT NULL, uuid UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE UNIQUE INDEX UNIQ_DD9F1B51D17F50A6 ON settlement (uuid)');
+        $this->addSql('COMMENT ON COLUMN settlement.uuid IS \'(DC2Type:uuid)\'');
+        $this->addSql('COMMENT ON COLUMN settlement.coordinates IS \'(DC2Type:array)\'');
+        $this->addSql('CREATE TABLE tags (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_6FBC9426B1E7706E ON tags (restaurant_id)');
+        $this->addSql('CREATE TABLE "user" (id INT NOT NULL, uuid UUID NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649D17F50A6 ON "user" (uuid)');
+        $this->addSql('COMMENT ON COLUMN "user".uuid IS \'(DC2Type:uuid)\'');
+        $this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
+        $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
+        $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
+        $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
+        $this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
+        $this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
+        $this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
+        $this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
+            BEGIN
+                PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
+                RETURN NEW;
+            END;
+        $$ LANGUAGE plpgsql;');
+        $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 address ADD CONSTRAINT FK_D4E6F81B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE email ADD CONSTRAINT FK_E7927C74B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE kitchen ADD CONSTRAINT FK_EAA3CE34B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $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_news_category ADD CONSTRAINT FK_1A91D6D6B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE news_news_category ADD CONSTRAINT FK_1A91D6D63B732BAD FOREIGN KEY (news_category_id) REFERENCES news_category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A5FB1909 FOREIGN KEY (news_id_id) REFERENCES news (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8ACEB712DF FOREIGN KEY (moderator_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A9D86650F FOREIGN KEY (user_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE phone ADD CONSTRAINT FK_444F97DDB1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F714819A0 FOREIGN KEY (type_id_id) REFERENCES restaurant_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F45EC589B FOREIGN KEY (settlement_id_id) REFERENCES settlement (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+        $this->addSql('ALTER TABLE tags ADD CONSTRAINT FK_6FBC9426B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('CREATE SCHEMA public');
+        $this->addSql('DROP SEQUENCE address_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE email_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE kitchen_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE news_comment_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE news_type_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE phone_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE restaurant_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE restaurant_type_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE settlement_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE tags_id_seq CASCADE');
+        $this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
+        $this->addSql('ALTER TABLE address DROP CONSTRAINT FK_D4E6F81B1E7706E');
+        $this->addSql('ALTER TABLE email DROP CONSTRAINT FK_E7927C74B1E7706E');
+        $this->addSql('ALTER TABLE kitchen DROP CONSTRAINT FK_EAA3CE34B1E7706E');
+        $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950C54C8C93');
+        $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D6B5A459A0');
+        $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D63B732BAD');
+        $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A5FB1909');
+        $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8ACEB712DF');
+        $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A9D86650F');
+        $this->addSql('ALTER TABLE phone DROP CONSTRAINT FK_444F97DDB1E7706E');
+        $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F714819A0');
+        $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F45EC589B');
+        $this->addSql('ALTER TABLE tags DROP CONSTRAINT FK_6FBC9426B1E7706E');
+        $this->addSql('DROP TABLE address');
+        $this->addSql('DROP TABLE email');
+        $this->addSql('DROP TABLE kitchen');
+        $this->addSql('DROP TABLE news');
+        $this->addSql('DROP TABLE news_news_category');
+        $this->addSql('DROP TABLE news_category');
+        $this->addSql('DROP TABLE news_comment');
+        $this->addSql('DROP TABLE news_type');
+        $this->addSql('DROP TABLE phone');
+        $this->addSql('DROP TABLE restaurant');
+        $this->addSql('DROP TABLE restaurant_type');
+        $this->addSql('DROP TABLE settlement');
+        $this->addSql('DROP TABLE tags');
+        $this->addSql('DROP TABLE "user"');
+        $this->addSql('DROP TABLE messenger_messages');
+    }
+}
diff --git a/src/Controller/RestaurantController.php b/src/Controller/RestaurantController.php
new file mode 100644
index 0000000..d1dc2fc
--- /dev/null
+++ b/src/Controller/RestaurantController.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Controller;
+
+use App\Service\RestaurantService;
+use Nelmio\ApiDocBundle\Annotation\Model;
+use OpenApi\Annotations as OA;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Attribute\Route;
+use App\Model\RestaurantList;
+
+#[Route("/api/v1")]
+class RestaurantController extends AbstractController
+{
+    public function __construct(private RestaurantService $restaurantService) {}
+
+    /**
+     @OA\OpenApi\Response(response=200, description="Листинг ресторанов")
+     * @OA\Parameter(
+     *     name="page",
+     *     in="query",
+     *     description="Номер страницы",
+     *     @OA\Schema(type="integer")
+     * )
+     * @Model(type=RestaurantList::class)
+     */
+    #[Route('/restaurants', name: 'restaurants', methods: ['GET'])]
+    public function index(int $page): Response
+    {
+        $restaurantsList = $this->restaurantService->getRestaurants();
+        return $this->json($restaurantsList);
+    }
+
+
+}
diff --git a/src/Mapper/RestaurantMapper.php b/src/Mapper/RestaurantMapper.php
new file mode 100644
index 0000000..53a7e12
--- /dev/null
+++ b/src/Mapper/RestaurantMapper.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Mapper;
+
+use App\Entity\Kitchen;
+use App\Entity\Restaurant;
+use App\Entity\RestaurantType;
+use App\Model\File;
+use App\Model\KitchenType;
+use App\Model\RestaurantListingElement;
+use App\Model\RestaurantType as RestaurantTypeModel;
+
+class RestaurantMapper
+{
+    public static function mapToListElement(Restaurant $restaurant): RestaurantListingElement
+    {
+        return new RestaurantListingElement(
+            $restaurant->getId(),
+            $restaurant->getName(),
+            $restaurant->getCode(),
+            new RestaurantTypeModel(
+                $restaurant->getTypeId()->getId(),
+                $restaurant->getTypeId()->getName(),
+                $restaurant->getTypeId()->getCode()
+            ),
+            $restaurant->getCheckInfo(),
+            new File(
+                1,
+                "name",
+                "description",
+                10,
+                "jpg",
+                $restaurant->getPreviewImage()
+            ),
+            $restaurant->getSite()
+        );
+    }
+
+    public static function mapToRestaurantType(RestaurantType $restaurantType): RestaurantTypeModel
+    {
+        return new RestaurantTypeModel(
+            $restaurantType->getId(),
+            $restaurantType->getName(),
+            $restaurantType->getCode(),
+        );
+    }
+
+    public static function mapToKitchenType(Kitchen $kitchen): KitchenType
+    {
+        return new KitchenType(
+            $kitchen->getId(),
+            $kitchen->getName()
+        );
+    }
+}
\ No newline at end of file
diff --git a/src/Repository/Interface/KitchenRepositoryInterface.php b/src/Repository/Interface/KitchenRepositoryInterface.php
new file mode 100644
index 0000000..b93005a
--- /dev/null
+++ b/src/Repository/Interface/KitchenRepositoryInterface.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Repository\Interface;
+
+interface KitchenRepositoryInterface
+{
+    public function getAll(): array;
+}
\ No newline at end of file
diff --git a/src/Repository/Interface/RestaurantRepositoryInterface.php b/src/Repository/Interface/RestaurantRepositoryInterface.php
new file mode 100644
index 0000000..f5fa2f2
--- /dev/null
+++ b/src/Repository/Interface/RestaurantRepositoryInterface.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Repository\Interface;
+
+interface RestaurantRepositoryInterface
+{
+    public function getAll(): array;
+}
\ No newline at end of file
diff --git a/src/Repository/Interface/RestaurantTypeRepositoryInterface.php b/src/Repository/Interface/RestaurantTypeRepositoryInterface.php
new file mode 100644
index 0000000..d8d965b
--- /dev/null
+++ b/src/Repository/Interface/RestaurantTypeRepositoryInterface.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Repository\Interface;
+
+interface RestaurantTypeRepositoryInterface
+{
+    public function getAll(): array;
+}
\ No newline at end of file
diff --git a/src/Service/RestaurantService.php b/src/Service/RestaurantService.php
new file mode 100644
index 0000000..d9f26f9
--- /dev/null
+++ b/src/Service/RestaurantService.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Service;
+
+use App\Entity\Kitchen;
+use App\Entity\Restaurant;
+use App\Entity\RestaurantType;
+use App\Mapper\RestaurantMapper;
+use App\Model\KitchenType;
+use App\Model\Pagination;
+use App\Model\RestaurantFilterVariants;
+use App\Model\RestaurantList;
+use App\Model\RestaurantListingElement;
+use App\Model\RestaurantType as RestaurantTypeModel;
+use App\Repository\Interface\KitchenRepositoryInterface;
+use App\Repository\Interface\RestaurantRepositoryInterface;
+use App\Repository\Interface\RestaurantTypeRepositoryInterface;
+use Ramsey\Collection\Collection;
+
+class RestaurantService
+{
+    public function __construct(
+        private RestaurantRepositoryInterface $restaurantRepository,
+        private RestaurantTypeRepositoryInterface $restaurantTypeRepository,
+        private KitchenRepositoryInterface $kitchenRepository,
+    ) {}
+
+    public function getRestaurants(): RestaurantList
+    {
+        $restaurants = $this->restaurantRepository->getAll();
+        $restaurantTypes = $this->restaurantTypeRepository->getAll();
+        $kitchens = $this->kitchenRepository->getAll();
+
+        return new RestaurantList(
+            new Pagination(1, floor(count($restaurants)) / 5, 16),
+            new Collection(RestaurantListingElement::class, array_map(
+            function (Restaurant $restaurant) {
+                return RestaurantMapper::mapToListElement($restaurant);
+            }, $restaurants)),
+            new RestaurantFilterVariants(
+                new Collection(
+                    RestaurantTypeModel::class, array_map(
+                        function (RestaurantType $restaurantType) {
+                            return RestaurantMapper::mapToRestaurantType($restaurantType);
+                        }, $restaurantTypes
+                    )
+                ),
+                new Collection(
+                    KitchenType::class, array_map(
+                        function (Kitchen $kitchen) {
+                            return RestaurantMapper::mapToKitchenType($kitchen);
+                        }, $kitchens
+                    ),
+                )
+            )
+        );
+    }
+}
\ No newline at end of file
-- 
GitLab