task manager

This commit is contained in:
2023-04-25 01:32:15 +03:00
parent 5508fcb1ee
commit 226f2daa34
18 changed files with 746 additions and 85 deletions

View File

@ -16,6 +16,7 @@ class TaskController extends ApiController
return [
'get-task' => ['get'],
'get-task-list' => ['get'],
'get-user-tasks' => ['get'],
'create-task' => ['post'],
'update-task' => ['put', 'patch'],
];
@ -36,9 +37,35 @@ class TaskController extends ApiController
/**
*
* @OA\Get(path="/task/get-task-list",
* summary="Получить список задач по проекту",
* description="Метод для получения задач по проекту",
* security={
* {"bearerAuth": {}}
* },
* tags={"TaskManager"},
* @OA\Parameter(
* name="project_id",
* in="query",
* required=true,
* @OA\Schema(
* type="integer",
* )
* ),
* @OA\Response(
* response=200,
* description="Возвращает массив объектов Задач",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/ProjectTaskExample"),
* ),
* ),
* )
*
* @throws NotFoundHttpException
*/
public function actionGetTaskList($project_id = null): array
public function actionGetTaskList($project_id): array
{
$tasks = array();
if ($project_id) {
@ -56,6 +83,55 @@ class TaskController extends ApiController
return $tasks;
}
/**
*
* @OA\Get(path="/task/get-user-tasks",
* summary="Получить список задач по пользователю",
* description="Метод для получения задач по пользователю",
* security={
* {"bearerAuth": {}}
* },
* tags={"TaskManager"},
* @OA\Parameter(
* name="user_id",
* in="query",
* required=true,
* @OA\Schema(
* type="integer",
* )
* ),
* @OA\Response(
* response=200,
* description="Возвращает массив объектов Задач",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/ProjectTaskExample"),
* ),
* ),
* )
*
* @param $user_id
* @return array
* @throws NotFoundHttpException
*/
public function actionGetUserTasks($user_id): array
{
$tasks = array();
if ($user_id) {
if (empty($user_id) or !is_numeric($user_id)) {
throw new NotFoundHttpException('Incorrect project ID');
}
$tasks = TaskService::getTaskListByUser($user_id);
} else {
$tasks = TaskService::getTaskList($user_id);
}
if (empty($tasks)) {
throw new NotFoundHttpException('The project does not exist or there are no tasks for it');
}
return $tasks;
}
/**
* @throws NotFoundHttpException
*/