project users, column priority
This commit is contained in:
parent
90eadd4830
commit
b0c350efbd
@ -15,6 +15,7 @@ use yii\db\Expression;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property int $status
|
* @property int $status
|
||||||
|
* @property int $priority
|
||||||
*
|
*
|
||||||
* @property Project $project
|
* @property Project $project
|
||||||
*/
|
*/
|
||||||
@ -43,6 +44,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
|||||||
'updated_at',
|
'updated_at',
|
||||||
'project_id',
|
'project_id',
|
||||||
'status',
|
'status',
|
||||||
|
'priority',
|
||||||
'tasks',
|
'tasks',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -62,7 +64,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['title', 'project_id'], 'required'],
|
[['title', 'project_id'], 'required'],
|
||||||
[['project_id', 'status'], 'integer'],
|
[['project_id', 'status', 'priority'], 'integer'],
|
||||||
[['created_at', 'updated_at'], 'safe'],
|
[['created_at', 'updated_at'], 'safe'],
|
||||||
[['title'], 'string', 'max' => 255],
|
[['title'], 'string', 'max' => 255],
|
||||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||||
@ -81,6 +83,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
|||||||
'created_at' => 'Дата создания',
|
'created_at' => 'Дата создания',
|
||||||
'updated_at' => 'Дата редактирования',
|
'updated_at' => 'Дата редактирования',
|
||||||
'status' => 'Статус',
|
'status' => 'Статус',
|
||||||
|
'priority' => 'Приоритет',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m230510_164429_add_priority_column_at_project_column_table
|
||||||
|
*/
|
||||||
|
class m230510_164429_add_priority_column_at_project_column_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->addColumn('project_column', 'priority', $this->integer(2)->defaultValue(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropColumn('project_column', 'priority');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use up()/down() to run migration code without a transaction.
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m230510_164429_add_priority_column_at_project_column_table cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -93,6 +93,11 @@ class ProjectColumnController extends ApiController
|
|||||||
* type="string",
|
* type="string",
|
||||||
* description="Название колонки",
|
* description="Название колонки",
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="priority",
|
||||||
|
* type="integer",
|
||||||
|
* description="Приоритет колонки",
|
||||||
|
* ),
|
||||||
* ),
|
* ),
|
||||||
* ),
|
* ),
|
||||||
* ),
|
* ),
|
||||||
@ -153,6 +158,11 @@ class ProjectColumnController extends ApiController
|
|||||||
* description="Идентификатор проекта",
|
* description="Идентификатор проекта",
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
|
* property="priority",
|
||||||
|
* type="integer",
|
||||||
|
* description="Приоритет колонки",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
* property="status",
|
* property="status",
|
||||||
* type="integer",
|
* type="integer",
|
||||||
* description="Статус колонки",
|
* description="Статус колонки",
|
||||||
|
@ -4,11 +4,11 @@ namespace frontend\modules\api\controllers;
|
|||||||
|
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
use common\models\ProjectTaskCategory;
|
use common\models\ProjectTaskCategory;
|
||||||
use common\models\ProjectUser;
|
|
||||||
use common\models\Status;
|
use common\models\Status;
|
||||||
use common\models\UseStatus;
|
use common\models\UseStatus;
|
||||||
use frontend\modules\api\models\Manager;
|
use frontend\modules\api\models\Manager;
|
||||||
use frontend\modules\api\models\Project;
|
use frontend\modules\api\models\Project;
|
||||||
|
use frontend\modules\api\models\ProjectUser;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
@ -35,6 +35,7 @@ class ProjectController extends ApiController
|
|||||||
'status-list' => ['GET', 'OPTIONS'],
|
'status-list' => ['GET', 'OPTIONS'],
|
||||||
'project-task-category-list' => ['GET', 'OPTIONS'],
|
'project-task-category-list' => ['GET', 'OPTIONS'],
|
||||||
'create' => ['POST', 'OPTIONS'],
|
'create' => ['POST', 'OPTIONS'],
|
||||||
|
'add-user' => ['POST', 'OPTIONS'],
|
||||||
'update' => ['PUT', 'OPTIONS']
|
'update' => ['PUT', 'OPTIONS']
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -375,10 +376,126 @@ class ProjectController extends ApiController
|
|||||||
|
|
||||||
$model = Manager::find()->with(['managerEmployees'])->where(['user_id' => $user_id])->one();
|
$model = Manager::find()->with(['managerEmployees'])->where(['user_id' => $user_id])->one();
|
||||||
|
|
||||||
if (!$model){
|
if (!$model) {
|
||||||
throw new BadRequestHttpException(json_encode(['Менеджер не найден']));
|
throw new BadRequestHttpException(json_encode(['Менеджер не найден']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @OA\Post(path="/project/add-user",
|
||||||
|
* summary="Добавить пользователя в проект",
|
||||||
|
* description="Метод для добавления пользователя в проект",
|
||||||
|
* security={
|
||||||
|
* {"bearerAuth": {}}
|
||||||
|
* },
|
||||||
|
* tags={"TaskManager"},
|
||||||
|
*
|
||||||
|
* @OA\RequestBody(
|
||||||
|
* @OA\MediaType(
|
||||||
|
* mediaType="multipart/form-data",
|
||||||
|
* @OA\Schema(
|
||||||
|
* required={"user_id", "project_id"},
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user_id",
|
||||||
|
* type="integer",
|
||||||
|
* description="Идентификатор пользователя",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="project_id",
|
||||||
|
* type="integer",
|
||||||
|
* description="Идентификатор проекта",
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Возвращает объект",
|
||||||
|
* @OA\MediaType(
|
||||||
|
* mediaType="application/json",
|
||||||
|
* @OA\Schema(ref="#/components/schemas/ProjectUsers"),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @return array|ProjectUser
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionAddUser()
|
||||||
|
{
|
||||||
|
$request = Yii::$app->request->post();
|
||||||
|
$project = Project::findOne($request['project_id']);
|
||||||
|
if (empty($project)) {
|
||||||
|
throw new NotFoundHttpException('The project not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = new ProjectUser();
|
||||||
|
$model->load($request, '');
|
||||||
|
if ($model->user->userCard){
|
||||||
|
$model->card_id = $model->user->userCard->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$model->save()){
|
||||||
|
return $model->errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @OA\Delete(path="/project/del-user",
|
||||||
|
* summary="Удаление пользователя из проекта",
|
||||||
|
* description="Метод для Удаления пользователя из проекта",
|
||||||
|
* security={
|
||||||
|
* {"bearerAuth": {}}
|
||||||
|
* },
|
||||||
|
* tags={"TaskManager"},
|
||||||
|
*
|
||||||
|
* @OA\RequestBody(
|
||||||
|
* @OA\MediaType(
|
||||||
|
* mediaType="application/x-www-form-urlencoded",
|
||||||
|
* @OA\Schema(
|
||||||
|
* required={"project_id", "user_id"},
|
||||||
|
* @OA\Property(
|
||||||
|
* property="project_id",
|
||||||
|
* type="integer",
|
||||||
|
* description="Идентификатор проекта",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user_id",
|
||||||
|
* type="integer",
|
||||||
|
* description="Идентификатор пользователя",
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Возвращает объект проекта",
|
||||||
|
* @OA\MediaType(
|
||||||
|
* mediaType="application/json",
|
||||||
|
* @OA\Schema(ref="#/components/schemas/Project"),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @return Project
|
||||||
|
* @throws \yii\base\InvalidConfigException
|
||||||
|
*/
|
||||||
|
public function actionDelUser(): Project
|
||||||
|
{
|
||||||
|
$request = Yii::$app->request->getBodyParams();
|
||||||
|
|
||||||
|
ProjectUser::deleteAll(['project_id' => $request['project_id'], 'user_id' => $request['user_id']]);
|
||||||
|
$project = Project::findOne($request['project_id']);
|
||||||
|
if (empty($project)) {
|
||||||
|
throw new NotFoundHttpException('The project not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $project;
|
||||||
|
}
|
||||||
}
|
}
|
@ -49,6 +49,10 @@ use yii\web\Linkable;
|
|||||||
* property="columns",
|
* property="columns",
|
||||||
* ref="#/components/schemas/ProjectColumnExample",
|
* ref="#/components/schemas/ProjectColumnExample",
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="projectUsers",
|
||||||
|
* ref="#/components/schemas/ProjectUsersExample",
|
||||||
|
* ),
|
||||||
*)
|
*)
|
||||||
*
|
*
|
||||||
* @OA\Schema(
|
* @OA\Schema(
|
||||||
@ -85,6 +89,10 @@ use yii\web\Linkable;
|
|||||||
* property="company",
|
* property="company",
|
||||||
* ref="#/components/schemas/Company",
|
* ref="#/components/schemas/Company",
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="projectUsers",
|
||||||
|
* ref="#/components/schemas/ProjectUsers",
|
||||||
|
* ),
|
||||||
* ),
|
* ),
|
||||||
*)
|
*)
|
||||||
*
|
*
|
||||||
@ -107,7 +115,7 @@ class Project extends \common\models\Project
|
|||||||
'company' => function() {
|
'company' => function() {
|
||||||
return $this->company;
|
return $this->company;
|
||||||
},
|
},
|
||||||
|
'projectUsers',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +124,14 @@ class Project extends \common\models\Project
|
|||||||
return ['columns',];
|
return ['columns',];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProjectUsers()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectUser::class, ['project_id' => 'id']);
|
||||||
|
}
|
||||||
|
|
||||||
public function getLinks(): array
|
public function getLinks(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -31,6 +31,12 @@ namespace frontend\modules\api\models;
|
|||||||
* description="Статус колонки"
|
* description="Статус колонки"
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
|
* property="priority",
|
||||||
|
* type="int",
|
||||||
|
* example="1",
|
||||||
|
* description="Приоритет колонки"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
* property="tasks",
|
* property="tasks",
|
||||||
* ref="#/components/schemas/ProjectTask",
|
* ref="#/components/schemas/ProjectTask",
|
||||||
* ),
|
* ),
|
||||||
@ -40,7 +46,7 @@ namespace frontend\modules\api\models;
|
|||||||
* schema="ProjectColumnExample",
|
* schema="ProjectColumnExample",
|
||||||
* type="array",
|
* type="array",
|
||||||
* example={
|
* example={
|
||||||
* {"id": 1, "title": "Задачи на проверку", "project_id": 95, "status": 1,
|
* {"id": 1, "title": "Задачи на проверку", "project_id": 95, "status": 1, "priority": 1,
|
||||||
* "tasks": {
|
* "tasks": {
|
||||||
* {"id": 95, "title": "Сложная задача", "project_id": 44, "column_id": 1, "user_id": 19, "description": "Описание задачи", "status": 1,
|
* {"id": 95, "title": "Сложная задача", "project_id": 44, "column_id": 1, "user_id": 19, "description": "Описание задачи", "status": 1,
|
||||||
* "taskUsers": {
|
* "taskUsers": {
|
||||||
@ -56,7 +62,7 @@ namespace frontend\modules\api\models;
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* },
|
* },
|
||||||
* {"id": 2, "title": "Новые задачи", "project_id": 95, "status": 1,
|
* {"id": 2, "title": "Новые задачи", "project_id": 95, "status": 1, "priority": 2,
|
||||||
* "tasks": {
|
* "tasks": {
|
||||||
* {"id": 97, "title": "Очень Сложная задача", "project_id": 44, "column_id": 2, "user_id": 19, "description": "Описание простой задачи", "status": 1},
|
* {"id": 97, "title": "Очень Сложная задача", "project_id": 44, "column_id": 2, "user_id": 19, "description": "Описание простой задачи", "status": 1},
|
||||||
* {"id": 98, "title": "Очень Простая задача", "project_id": 44, "column_id": 2, "user_id": 19, "description": "Описание очень простой задачи", "status": 1}
|
* {"id": 98, "title": "Очень Простая задача", "project_id": 44, "column_id": 2, "user_id": 19, "description": "Описание очень простой задачи", "status": 1}
|
||||||
@ -82,6 +88,10 @@ namespace frontend\modules\api\models;
|
|||||||
* type="int",
|
* type="int",
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
|
* property="priority",
|
||||||
|
* type="int",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
* property="tasks",
|
* property="tasks",
|
||||||
* ref="#/components/schemas/ProjectTask",
|
* ref="#/components/schemas/ProjectTask",
|
||||||
* ),
|
* ),
|
||||||
|
70
frontend/modules/api/models/ProjectUser.php
Normal file
70
frontend/modules/api/models/ProjectUser.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\modules\api\models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @OA\Schema(
|
||||||
|
* schema="ProjectUsers",
|
||||||
|
* @OA\Property(
|
||||||
|
* property="project_id",
|
||||||
|
* type="int",
|
||||||
|
* example=1,
|
||||||
|
* description="Идентификатор проекта"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user_id",
|
||||||
|
* type="int",
|
||||||
|
* example=1,
|
||||||
|
* description="Идентификатор пользователя"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user",
|
||||||
|
* ref="#/components/schemas/ProjectTaskUsersShortExample",
|
||||||
|
* description="Пользователи проекта"
|
||||||
|
* ),
|
||||||
|
*)
|
||||||
|
*
|
||||||
|
* @OA\Schema(
|
||||||
|
* schema="ProjectUsersExample",
|
||||||
|
* type="array",
|
||||||
|
* example={
|
||||||
|
* {"project_id": 20, "user_id": 19, "user": {"fio": "Иванов Иван Иванович", "avatar": "/profileava/m6.png"}},
|
||||||
|
* {"project_id": 20, "user_id": 20, "user": {"fio": "Петров Петр Петрович", "avatar": "/profileava/m2.png"}},
|
||||||
|
* },
|
||||||
|
* @OA\Items(
|
||||||
|
* type="object",
|
||||||
|
* @OA\Property(
|
||||||
|
* property="project_id",
|
||||||
|
* type="integer",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user_id",
|
||||||
|
* type="integer",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user",
|
||||||
|
* ref="#/components/schemas/ProjectTaskUsersShortExample",
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
*)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ProjectUser extends \common\models\ProjectUser
|
||||||
|
{
|
||||||
|
|
||||||
|
public function fields()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'project_id',
|
||||||
|
'user_id',
|
||||||
|
'user' => function(){
|
||||||
|
return [
|
||||||
|
'fio' => $this->user->userCard->fio ?? $this->user->email,
|
||||||
|
'avatar' => $this->user->userCard->photo ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user