task priority, comments
This commit is contained in:
136
frontend/modules/api/controllers/CommentController.php
Normal file
136
frontend/modules/api/controllers/CommentController.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -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",
|
||||
|
63
frontend/modules/api/models/Comment.php
Normal file
63
frontend/modules/api/models/Comment.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
@ -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",
|
||||
|
Reference in New Issue
Block a user