From 1a250c4b008a6792678203b4c059236ded76f23a Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 12 Feb 2024 22:56:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=82=D0=B8=D0=BF=D0=B0=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D1=86=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/models/Entity.php | 3 +++ common/models/Project.php | 19 +++++++++++++++++++ .../api/controllers/ProjectController.php | 2 +- .../api/controllers/RequestController.php | 6 +++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common/models/Entity.php b/common/models/Entity.php index 65e61a3..d0d6521 100644 --- a/common/models/Entity.php +++ b/common/models/Entity.php @@ -8,6 +8,8 @@ class Entity const ENTITY_TYPE_PROJECT = 1; const ENTITY_TYPE_TASK = 2; + const ENTITY_TYPE_REQUEST = 3; + /** * @return string[] */ @@ -16,6 +18,7 @@ class Entity return [ self::ENTITY_TYPE_PROJECT => "Проект", self::ENTITY_TYPE_TASK => "Задача", + self::ENTITY_TYPE_REQUEST => "Запрос на создание проекта", ]; } diff --git a/common/models/Project.php b/common/models/Project.php index ce8b7ab..1ffa3e9 100755 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -88,6 +88,25 @@ class Project extends \yii\db\ActiveRecord ]; } + /** + * @param $insert + * @param $changedAttributes + * @return void + */ + public function afterSave($insert, $changedAttributes): void + { + if ($insert) { + $model = new ProjectUser(); + $model->user_id = $this->owner_id; + $model->project_id = $this->id; + $model->status = 1; + if ($model->save()) { + + } + } + parent::afterSave($insert, $changedAttributes); + } + /** * @return ActiveQuery */ diff --git a/frontend/modules/api/controllers/ProjectController.php b/frontend/modules/api/controllers/ProjectController.php index 1ca0828..a4b27f7 100644 --- a/frontend/modules/api/controllers/ProjectController.php +++ b/frontend/modules/api/controllers/ProjectController.php @@ -197,7 +197,7 @@ class ProjectController extends ApiController ->one(); if (empty($projectTaskCategory)) { - throw new NotFoundHttpException('The project not found'); + throw new BadRequestHttpException('This user cannot be added to the project'); } $projectTaskCategory->title = Yii::$app->request->post('new_title'); diff --git a/frontend/modules/api/controllers/RequestController.php b/frontend/modules/api/controllers/RequestController.php index 3845547..b77a951 100644 --- a/frontend/modules/api/controllers/RequestController.php +++ b/frontend/modules/api/controllers/RequestController.php @@ -82,8 +82,8 @@ class RequestController extends ApiController /** * * @OA\Get(path="/request/get-request-list", - * summary="Создать запрос", - * description="Метод для создания запроса, если параметр user_id не передан, то запрос создается от имени текущего пользователя.", + * summary="Получить список запросов", + * description="Метод для получения списка запросов, если параметр user_id не передан, то запрос создается от имени текущего пользователя.", * security={ * {"bearerAuth": {}} * }, @@ -108,7 +108,7 @@ class RequestController extends ApiController * ), * @OA\Response( * response=200, - * description="Возвращает объект Запроса", + * description="Возвращает массив объектов Запроса", * @OA\MediaType( * mediaType="application/json", * @OA\Schema(ref="#/components/schemas/RequestsExample"),