task priority, comments

This commit is contained in:
2023-05-12 02:12:43 +03:00
parent d6f5ffcd26
commit 7eab647ff7
25 changed files with 887 additions and 7 deletions

View File

@ -0,0 +1,136 @@
<?php
namespace frontend\modules\api\controllers;
use frontend\modules\api\models\Comment;
use yii\web\BadRequestHttpException;
class CommentController extends ApiController
{
public function verbs(): array
{
return [
'get-entity-type-list' => ['get'],
'create' => ['post'],
];
}
/**
*
* @OA\Get(path="/comment/get-entity-type-list",
* summary="Список типов сущностей",
* description="Получить список всех возможных типов сущностей",
* tags={"Comment"},
* security={
* {"bearerAuth": {}}
* },
* @OA\Response(
* response=200,
* description="Возвращает массив",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="array",
* @OA\Items(
* @OA\Property(
* property="id",
* type="integer",
* example="1",
* ),
* @OA\Property(
* property="name",
* type="string",
* example="Проект",
* ),
* )
* ),
* ),
*
* ),
* )
*
* @return array
*/
public function actionGetEntityTypeList(): array
{
$arr = [];
foreach (Comment::getEntityTypeList() as $key => $value) {
$arr[] = ["id" => $key, "name" => $value];
}
return $arr;
}
/**
*
* @OA\Post(path="/comment/create",
* summary="Добавить комментарий",
* description="Метод для создания комментария",
* security={
* {"bearerAuth": {}}
* },
* tags={"Comment"},
*
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* required={"text"},
* @OA\Property(
* property="text",
* type="string",
* description="Текст комментария",
* ),
* @OA\Property(
* property="entity_type",
* type="integer",
* description="Тип сущности",
* ),
* @OA\Property(
* property="entity_id",
* type="integer",
* description="Идентификатор сущности",
* ),
* @OA\Property(
* property="status",
* type="integer",
* description="Статус комментария",
* ),
* ),
* ),
* ),
* @OA\Response(
* response=200,
* description="Возвращает объект комментария",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/Comment"),
* ),
* ),
* )
*
* @return array|Comment
* @throws BadRequestHttpException
*/
public function actionCreate()
{
$model = new Comment();
$request = \Yii::$app->request->post();
$user_id = \Yii::$app->user->id;
if (!$user_id) {
throw new BadRequestHttpException(json_encode(['User not found']));
}
$request['user_id'] = $user_id;
$model->load($request, '');
if (!$model->save()){
return $model->errors;
}
return $model;
}
}

View File

@ -59,6 +59,11 @@ class TaskController extends ApiController
* description="статус",
* ),
* @OA\Property(
* property="priority",
* type="integer",
* description="Приоритет задачи",
* ),
* @OA\Property(
* property="column_id",
* type="integer",
* description="Колонка к которой относится задача",
@ -275,9 +280,14 @@ class TaskController extends ApiController
* description="Идентификатор колонки",
* ),
* @OA\Property(
* property="priority",
* type="integer",
* description="Приоритет задачи",
* ),
* @OA\Property(
* property="status",
* type="integer",
* description="Статус запроса",
* description="Статус задачи",
* ),
* @OA\Property(
* property="description",

View File

@ -0,0 +1,63 @@
<?php
namespace frontend\modules\api\models;
/**
*
* @OA\Schema(
* schema="Comment",
* @OA\Property(
* property="id",
* type="int",
* example=12,
* description="Идентификатор комментария"
* ),
* @OA\Property(
* property="text",
* type="string",
* example="Очень хорошая задача",
* description="Текст комментария"
* ),
* @OA\Property(
* property="created_at",
* type="datetime",
* example="2023-04-07 02:09:42",
* description="Дата и время создания"
* ),
* @OA\Property(
* property="updated_at",
* type="datetime",
* example="2023-04-10 16:20:48",
* description="Дата и время обновления"
* ),
* @OA\Property(
* property="user_id",
* type="integer",
* example=19,
* description="Идентификатор пользователя"
* ),
* @OA\Property(
* property="entity_type",
* type="int",
* example=2,
* description="Идентификатор типа сущности комментария"
* ),
* @OA\Property(
* property="entity_id",
* type="int",
* example=2,
* description="Идентификатор сущности комментария"
* ),
* @OA\Property(
* property="status",
* type="integer",
* example="1",
* description="Статус"
* ),
*)
*
*/
class Comment extends \common\models\Comment
{
}

View File

@ -59,10 +59,16 @@ namespace frontend\modules\api\models;
* description="Описание задачи"
* ),
* @OA\Property(
* property="priority",
* type="int",
* example="1",
* description="Приоритет задачи"
* ),
* @OA\Property(
* property="status",
* type="int",
* example="1",
* description="Статус колонки"
* description="Статус задачи"
* ),
* @OA\Property(
* property="taskUsers",