diff --git a/frontend/modules/api/controllers/TaskController.php b/frontend/modules/api/controllers/TaskController.php index b559216..fe3df56 100644 --- a/frontend/modules/api/controllers/TaskController.php +++ b/frontend/modules/api/controllers/TaskController.php @@ -147,6 +147,15 @@ class TaskController extends ApiController * ) * ), * @OA\Parameter( + * name="user_id", + * description="При передаче этого параметера вернёт все задачи на проекте для пользователя с заданным id", + * in="query", + * required=false, + * @OA\Schema( + * type="integer", + * ) + * ), + * @OA\Parameter( * name="expand", * in="query", * example="column,timers,mark", @@ -167,9 +176,9 @@ class TaskController extends ApiController * * @throws NotFoundHttpException */ - public function actionGetTaskList($project_id): array + public function actionGetTaskList($project_id, $user_id = null): array { - $tasks = $this->taskService->getTaskListByProject($project_id); + $tasks = $this->taskService->getTaskListByProject($project_id, $user_id); if (empty($tasks)) { throw new NotFoundHttpException('The project does not exist or there are no tasks for it'); diff --git a/frontend/modules/api/services/TaskService.php b/frontend/modules/api/services/TaskService.php index 809a42e..67dcdbc 100644 --- a/frontend/modules/api/services/TaskService.php +++ b/frontend/modules/api/services/TaskService.php @@ -35,9 +35,14 @@ class TaskService return ProjectTask::find()->asArray()->all(); } - public function getTaskListByProject($project_id): array + public function getTaskListByProject($project_id, $user_id): array { - return ProjectTask::find()->where(['project_id' => $project_id])->orderBy('priority DESC')->all(); + $query = ProjectTask::find()->where(['project_id' => $project_id]); + + if ($user_id) { + $query->andWhere(['user_id' => $user_id]); + } + return $query->orderBy('priority DESC')->all(); } public function getArchiveTask($project_id, $user_id): array