task manager
This commit is contained in:
parent
5508fcb1ee
commit
226f2daa34
@ -18,7 +18,7 @@ class TaskSearch extends ProjectTask
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'project_id', 'status', 'card_id_creator', 'card_id'], 'integer'], // 'card_id_creator', 'card_id'
|
||||
[['id', 'project_id', 'status'], 'integer'], // 'card_id_creator', 'card_id'
|
||||
[['title', 'created_at', 'updated_at', 'description'], 'safe'],
|
||||
];
|
||||
}
|
||||
@ -64,8 +64,6 @@ class TaskSearch extends ProjectTask
|
||||
'task.status' => $this->status,
|
||||
'task.created_at' => $this->created_at,
|
||||
'task.updated_at' => $this->updated_at,
|
||||
'task.card_id_creator' => $this->card_id_creator,
|
||||
'task.card_id' => $this->card_id,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'title', $this->title])
|
||||
|
@ -24,13 +24,13 @@ use yii\widgets\ActiveForm;
|
||||
);
|
||||
?>
|
||||
|
||||
<?= $form->field($model, 'card_id_creator')->widget(Select2::class,
|
||||
<?= $form->field($model, 'user_id')->widget(
|
||||
Select2::class,
|
||||
[
|
||||
'data' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control', 'value' => Yii::$app->user->id],
|
||||
'data' => \common\models\UserCard::getListUserWithUserId(),
|
||||
'options' => ['placeholder' => '...', 'class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true,
|
||||
'prompt' => 'Выберите'
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
@ -44,9 +44,9 @@ use yii\widgets\ActiveForm;
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'card_id')->widget(Select2::class,
|
||||
<?= $form->field($model, 'column_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
|
||||
'data' => \common\models\ProjectColumn::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true,
|
||||
|
@ -49,42 +49,6 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
])
|
||||
],
|
||||
'title',
|
||||
[
|
||||
'attribute' => 'card_id_creator',
|
||||
'value' => 'userCardCreator.fio',
|
||||
'filter' => Select2::widget([
|
||||
'model' => $searchModel,
|
||||
'attribute' => 'card_id_creator',
|
||||
'data' => ProjectTask::find()->joinWith('userCardCreator')
|
||||
->select(['user_card.fio', 'user_card.id'])->indexBy('user_card.id')->column(),
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true,
|
||||
'width' => '150px',
|
||||
],
|
||||
'options' => [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'Выберите значение'
|
||||
],
|
||||
])
|
||||
],
|
||||
[
|
||||
'attribute' => 'card_id',
|
||||
'value' => 'userCard.fio',
|
||||
'filter' => Select2::widget([
|
||||
'model' => $searchModel,
|
||||
'attribute' => 'card_id',
|
||||
'data' => ProjectTask::find()->joinWith('userCard')
|
||||
->select(['user_card.fio', 'user_card.id'])->indexBy('user_card.id')->column(),
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true,
|
||||
'width' => '150px',
|
||||
],
|
||||
'options' => [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'Выберите значение'
|
||||
],
|
||||
])
|
||||
],
|
||||
'description',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
|
@ -47,12 +47,12 @@ YiiAsset::register($this);
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'card_id_creator',
|
||||
'value' => ArrayHelper::getValue($model, 'userCardCreator.fio'),
|
||||
'attribute' => 'column_id',
|
||||
'value' => ArrayHelper::getValue($model, 'column.title'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'card_id',
|
||||
'value' => ArrayHelper::getValue($model, 'userCard.fio'),
|
||||
'attribute' => 'user_id',
|
||||
'value' => ArrayHelper::getValue($model, 'user.userCard.fio'),
|
||||
],
|
||||
'description',
|
||||
],
|
||||
|
@ -101,6 +101,14 @@ class Project extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(Company::class, ['id' => 'company_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->hasMany(ProjectColumn::class, ['project_id' => 'id'])->with('tasks');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
{
|
||||
const STATUS_ACTIVE = 1;
|
||||
const STATUS_DISABLE = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -30,6 +31,30 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
return 'project_column';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'title',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'project_id',
|
||||
'status',
|
||||
'tasks',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -92,4 +117,12 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getTasks()
|
||||
{
|
||||
return $this->hasMany(ProjectTask::class, ['column_id' => 'id'])->with('taskUsers');
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $status
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $card_id_creator
|
||||
* @property int $card_id
|
||||
* @property int $column_id
|
||||
* @property int $user_id
|
||||
* @property string $description
|
||||
*
|
||||
* @property Project $project
|
||||
@ -54,15 +54,15 @@ class ProjectTask extends ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['project_id', 'status', 'title', 'description', 'card_id_creator',], 'required'],
|
||||
[['project_id', 'status', 'card_id_creator', 'card_id'], 'integer'],
|
||||
[['project_id', 'status', 'title', 'description',], 'required'],
|
||||
[['project_id', 'status', 'column_id', 'user_id'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message'=>'Такая задача уже создана'],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['description'], 'string', 'max' => 500],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
|
||||
[['card_id_creator'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id_creator' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['column_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectColumn::className(), 'targetAttribute' => ['column_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -79,14 +79,33 @@ class ProjectTask extends ActiveRecord
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата обновления',
|
||||
'description' => 'Описание',
|
||||
'card_id_creator' => 'Создатель задачи',
|
||||
'card_id' => 'Наблюдатель',
|
||||
'user_id' => 'Создатель задачи',
|
||||
'column_id' => 'Колонка',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'project_id',
|
||||
'title',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'description',
|
||||
'status',
|
||||
'column_id',
|
||||
'user_id',
|
||||
'taskUsers',
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeDelete()
|
||||
{
|
||||
foreach ($this->taskUsers as $taskUser){
|
||||
foreach ($this->taskUsers as $taskUser) {
|
||||
$taskUser->delete();
|
||||
}
|
||||
return parent::beforeDelete();
|
||||
@ -108,14 +127,12 @@ class ProjectTask extends ActiveRecord
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
public function getUserCard()
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getColumn(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
|
||||
}
|
||||
|
||||
public function getUserCardCreator()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id_creator']);
|
||||
return $this->hasOne(ProjectColumn::class, ['id' => 'column_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,7 @@ use yii\db\ActiveQuery;
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $task_id
|
||||
* @property int $project_user_id
|
||||
* @property int $user_id
|
||||
*
|
||||
* @property ProjectUser $projectUser
|
||||
* @property ProjectTask $task
|
||||
@ -30,13 +30,31 @@ class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['task_id', 'project_user_id'], 'required'],
|
||||
['project_user_id', 'unique', 'targetAttribute' => ['task_id', 'project_user_id'], 'message'=>'Уже закреплён(ы) за задачей'],
|
||||
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
|
||||
[['task_id', 'user_id'], 'required'],
|
||||
['user_id', 'unique', 'targetAttribute' => ['task_id', 'user_id'], 'message' => 'Уже закреплён(ы) за задачей'],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectTask::className(), 'targetAttribute' => ['task_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'task_id',
|
||||
'user_id',
|
||||
'fio' => function () {
|
||||
return $this->user->userCard->fio ?? $this->user->username;
|
||||
},
|
||||
'avatar' => function () {
|
||||
return $this->user->userCard->photo ?? '';
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -45,16 +63,13 @@ class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'task_id' => 'Задача',
|
||||
'project_user_id' => 'Сотрудник',
|
||||
'user_id' => 'Сотрудник',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectUser()
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
|
||||
return $this->hasOne(User::class, ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,6 +29,11 @@ class TaskService
|
||||
return ProjectTask::find()->where(['project_id' => $project_id])->asArray()->all();
|
||||
}
|
||||
|
||||
public static function getTaskListByUser($user_id): array
|
||||
{
|
||||
return ProjectTask::find()->where(['user_id' => $user_id])->all();
|
||||
}
|
||||
|
||||
public static function updateTask($task_params): ?ProjectTask
|
||||
{
|
||||
$modelTask = ProjectTask::findOne($task_params['task_id']);
|
||||
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230420_211818_change_user_card_to_user_at_project_task_table
|
||||
*/
|
||||
class m230420_211818_change_user_card_to_user_at_project_task_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropForeignKey('task_user_card_creator', 'project_task');
|
||||
$this->dropForeignKey('task_user_card', 'project_task');
|
||||
$this->dropColumn('project_task', 'card_id_creator');
|
||||
$this->dropColumn('project_task', 'card_id');
|
||||
|
||||
$this->addColumn('project_task', 'column_id', $this->integer());
|
||||
$this->addColumn('project_task', 'user_id', $this->integer());
|
||||
$this->addForeignKey('fk_project_task_column', 'project_task', 'column_id', 'project_column', 'id');
|
||||
$this->addForeignKey('fk_project_task_user', 'project_task', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('fk_project_task_column', 'project_task');
|
||||
$this->dropForeignKey('fk_project_task_user', 'project_task');
|
||||
$this->dropColumn('project_task', 'column_id');
|
||||
$this->dropColumn('project_task', 'user_id');
|
||||
|
||||
$this->addColumn('project_task', 'card_id_creator', $this->integer());
|
||||
$this->addColumn('project_task', 'card_id', $this->integer());
|
||||
$this->addForeignKey('task_user_card_creator', 'project_task', 'card_id_creator', 'user_card', 'id');
|
||||
$this->addForeignKey('task_user_card', 'project_task', 'card_id', 'user_card', 'id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230420_211818_change_user_card_to_user_at_project_task_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230420_221309_change_column_project_user_id_to_user_id_at_project_task_user_table
|
||||
*/
|
||||
class m230420_221309_change_column_project_user_id_to_user_id_at_project_task_user_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropForeignKey('project_user_task_user', 'project_task_user');
|
||||
$this->dropColumn('project_task_user', 'project_user_id');
|
||||
|
||||
$this->addColumn('project_task_user', 'user_id', $this->integer());
|
||||
$this->addForeignKey('fk_project_task_user_user', 'project_task_user', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('fk_project_task_user_user', 'project_task_user');
|
||||
$this->dropColumn('project_task_user', 'user_id');
|
||||
|
||||
$this->addColumn('project_task_user', 'project_user_id', $this->integer());
|
||||
$this->addForeignKey('project_user_task_user', 'project_task_user', 'project_user_id', 'project_user', 'id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230420_221309_change_column_project_user_id_to_user_id_at_project_task_user_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
129
frontend/modules/api/controllers/ProjectColumnController.php
Normal file
129
frontend/modules/api/controllers/ProjectColumnController.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use common\models\ProjectColumn;
|
||||
use frontend\modules\api\models\Project;
|
||||
use yii\web\BadRequestHttpException;
|
||||
|
||||
class ProjectColumnController extends ApiController
|
||||
{
|
||||
|
||||
public function verbs(): array
|
||||
{
|
||||
return [
|
||||
'get-column' => ['get'],
|
||||
'get-column-list' => ['get'],
|
||||
'create-column' => ['post'],
|
||||
'update-column' => ['put', 'patch'],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionGetColumn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @OA\Get(path="/project-column/get-column-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/ProjectColumnExample"),
|
||||
* ),
|
||||
* ),
|
||||
* )
|
||||
*
|
||||
* @param $project_id
|
||||
* @return array|\yii\db\ActiveRecord[]
|
||||
* @throws BadRequestHttpException
|
||||
*/
|
||||
public function actionGetColumnList($project_id)
|
||||
{
|
||||
$project = Project::findOne($project_id);
|
||||
if (!$project) {
|
||||
throw new BadRequestHttpException(json_encode(['Проект не найден']));
|
||||
}
|
||||
|
||||
$columns = \frontend\modules\api\models\ProjectColumn::find()->where(['project_id' => $project_id])->all();
|
||||
|
||||
return $columns;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @OA\Post(path="/project-column/create-column",
|
||||
* summary="Добавить колонку",
|
||||
* description="Метод для создания колонки",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
* tags={"TaskManager"},
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* @OA\MediaType(
|
||||
* mediaType="multipart/form-data",
|
||||
* @OA\Schema(
|
||||
* required={"project_id", "title"},
|
||||
* @OA\Property(
|
||||
* property="project_id",
|
||||
* type="integer",
|
||||
* description="Идентификатор проекта",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* description="Название колонки",
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает объект колонки",
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(ref="#/components/schemas/ProjectColumn"),
|
||||
* ),
|
||||
* ),
|
||||
* )
|
||||
*
|
||||
* @return array|ProjectColumn
|
||||
*/
|
||||
public function actionCreateColumn()
|
||||
{
|
||||
$column = new ProjectColumn();
|
||||
$column->load(\Yii::$app->request->post(), '');
|
||||
|
||||
if ($column->validate()) {
|
||||
$column->save(false);
|
||||
return $column;
|
||||
}
|
||||
return $column->errors;
|
||||
|
||||
}
|
||||
|
||||
public function actionUpdateColumn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\ProjectTaskCategory;
|
||||
use common\models\ProjectUser;
|
||||
use common\models\Status;
|
||||
@ -10,6 +11,7 @@ use frontend\modules\api\models\Project;
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class ProjectController extends ApiController
|
||||
@ -38,9 +40,49 @@ class ProjectController extends ApiController
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionGetProject($project_id): ?Project
|
||||
/**
|
||||
*
|
||||
* @OA\Get(path="/project/get-project",
|
||||
* summary="Получить данные проекта",
|
||||
* description="Метод для получения проета",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
* tags={"TaskManager"},
|
||||
* @OA\Parameter(
|
||||
* name="project_id",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer",
|
||||
* default=null
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="expand",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* description="В этом параметре по необходимости передаются поля, которые нужно добавить в ответ сервера, сейчас доступно только поле <b>columns</b>",
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает массив объектов проекта",
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(ref="#/components/schemas/Project"),
|
||||
* ),
|
||||
* ),
|
||||
* )
|
||||
*
|
||||
* @param $project_id
|
||||
* @return array|Project|\yii\db\ActiveRecord|null
|
||||
*/
|
||||
public function actionGetProject($project_id)
|
||||
{
|
||||
return Project::findOne($project_id);
|
||||
return Project::find()->with('columns')->where(['id' => $project_id])->one();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +103,16 @@ class ProjectController extends ApiController
|
||||
* default=null
|
||||
* )
|
||||
* ),
|
||||
|
||||
* @OA\Parameter(
|
||||
* name="expand",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* description="В этом параметре по необходимости передаются поля, которые нужно добавить в ответ сервера, сейчас доступно только поле <b>columns</b>",
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает массив объектов проекта",
|
||||
@ -134,10 +185,66 @@ class ProjectController extends ApiController
|
||||
return $projectTaskCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @OA\Post(path="/project/create",
|
||||
* summary="Добавить проект",
|
||||
* description="Метод для создания проекта, если не передан параметр <b>user_id</b>, то будет получен текущий пользователь",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
* tags={"TaskManager"},
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* @OA\MediaType(
|
||||
* mediaType="multipart/form-data",
|
||||
* @OA\Schema(
|
||||
* required={"name", "status"},
|
||||
* @OA\Property(
|
||||
* property="name",
|
||||
* type="string",
|
||||
* description="Название проекта",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="description",
|
||||
* type="string",
|
||||
* description="Описание проекта",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="status",
|
||||
* type="integer",
|
||||
* description="статус",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="company_id",
|
||||
* type="integer",
|
||||
* description="Компания к которой относится проект",
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает объект Проекта",
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(ref="#/components/schemas/Project"),
|
||||
* ),
|
||||
* ),
|
||||
* )
|
||||
*
|
||||
* @return array|Project
|
||||
* @throws BadRequestHttpException
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$project = new Project();
|
||||
$project->attributes = \yii::$app->request->post();
|
||||
$user_id = \Yii::$app->user->id;
|
||||
if (!$user_id) {
|
||||
throw new BadRequestHttpException(json_encode(['Пользователь не найден']));
|
||||
}
|
||||
$project->load(\yii::$app->request->post(), '');
|
||||
$project->owner_id = $user_id;
|
||||
|
||||
if($project->validate()) {
|
||||
$project->save(false);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ use yii\web\Linkable;
|
||||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="int",
|
||||
* example=1,
|
||||
* example=95,
|
||||
* description="Идентификатор проекта"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
@ -45,6 +45,10 @@ use yii\web\Linkable;
|
||||
* property="company",
|
||||
* ref="#/components/schemas/Company",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="columns",
|
||||
* ref="#/components/schemas/ProjectColumnExample",
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
* @OA\Schema(
|
||||
@ -100,13 +104,14 @@ class Project extends \common\models\Project
|
||||
'owner_id',
|
||||
'company' => function() {
|
||||
return $this->company;
|
||||
}
|
||||
},
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [];
|
||||
return ['columns',];
|
||||
}
|
||||
|
||||
public function getLinks(): array
|
||||
|
95
frontend/modules/api/models/ProjectColumn.php
Normal file
95
frontend/modules/api/models/ProjectColumn.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
/**
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProjectColumn",
|
||||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="int",
|
||||
* example=95,
|
||||
* description="Идентификатор колонки"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* example="Задачи на проверку",
|
||||
* description="Название колонки"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="project_id",
|
||||
* type="int",
|
||||
* example="95",
|
||||
* description="Проект к которому относится колонка"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="status",
|
||||
* type="int",
|
||||
* example="1",
|
||||
* description="Статус колонки"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="tasks",
|
||||
* ref="#/components/schemas/ProjectTask",
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProjectColumnExample",
|
||||
* type="array",
|
||||
* example={
|
||||
* {"id": 1, "title": "Задачи на проверку", "project_id": 95, "status": 1,
|
||||
* "tasks": {
|
||||
* {"id": 95, "title": "Сложная задача", "project_id": 44, "column_id": 1, "user_id": 19, "description": "Описание задачи", "status": 1,
|
||||
* "taskUsers": {
|
||||
* {"id": 2, "task_id": 95, "user_id": 2, "fio": "Сапронов Антон Викторович", "avatar": "/profileava/m8.png"},
|
||||
* {"id": 3, "task_id": 95, "user_id": 3, "fio": "Иванов Иван Иванович", "avatar": "/profileava/m2.png"},
|
||||
* }
|
||||
* },
|
||||
* {"id": 96, "title": "Простая задача", "project_id": 44, "column_id": 1, "user_id": 19, "description": "Описание простой задачи", "status": 1,
|
||||
* "taskUsers": {
|
||||
* {"id": 3, "task_id": 96, "user_id": 3, "fio": "Иванов Иван Иванович", "avatar": "/profileava/m2.png"},
|
||||
* {"id": 4, "task_id": 96, "user_id": 4, "fio": "Петров Петр Петрович", "avatar": "/profileava/m7.png"},
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* },
|
||||
* {"id": 2, "title": "Новые задачи", "project_id": 95, "status": 1,
|
||||
* "tasks": {
|
||||
* {"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}
|
||||
* }
|
||||
* }
|
||||
* },
|
||||
* @OA\Items(
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="int",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="project_id",
|
||||
* type="int",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="status",
|
||||
* type="int",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="tasks",
|
||||
* ref="#/components/schemas/ProjectTask",
|
||||
* ),
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
*/
|
||||
class ProjectColumn extends \common\models\ProjectColumn
|
||||
{
|
||||
|
||||
}
|
104
frontend/modules/api/models/ProjectTask.php
Normal file
104
frontend/modules/api/models/ProjectTask.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
/**
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProjectTask",
|
||||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="int",
|
||||
* example=95,
|
||||
* description="Идентификатор задачи"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* example="Задачи на проверку",
|
||||
* description="Заголовок задачи"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="project_id",
|
||||
* type="int",
|
||||
* example="95",
|
||||
* description="Проект к которому относится задача"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="column_id",
|
||||
* type="int",
|
||||
* example="23",
|
||||
* description="Колонка к которой относится задача"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="user_id",
|
||||
* type="int",
|
||||
* example="19",
|
||||
* description="Пользователь создавший задачу"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="description",
|
||||
* type="string",
|
||||
* example="Описание задачи",
|
||||
* description="Описание задачи"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="status",
|
||||
* type="int",
|
||||
* example="1",
|
||||
* description="Статус колонки"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="taskUsers",
|
||||
* ref="#/components/schemas/ProjectTaskUsersExample",
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProjectTaskExample",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* type="object",
|
||||
* ref="#/components/schemas/ProjectTask",
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProjectTaskUsersExample",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="integer",
|
||||
* example="1"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="task_id",
|
||||
* type="integer",
|
||||
* example="1"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="user_id",
|
||||
* type="integer",
|
||||
* example="19"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="fio",
|
||||
* type="string",
|
||||
* example="Сапронов Антон Викторович"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="avatar",
|
||||
* type="string",
|
||||
* example="/profileava/m8.png"
|
||||
* ),
|
||||
* ),
|
||||
*)
|
||||
*
|
||||
*/
|
||||
class ProjectTask extends \common\models\ProjectTask
|
||||
{
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="Skill",
|
||||
|
Loading…
Reference in New Issue
Block a user