project Employees
This commit is contained in:
parent
1b8ca5b695
commit
b2f482e10b
@ -50,6 +50,21 @@ class ManagerEmployee extends \yii\db\ActiveRecord
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id',
|
||||||
|
'manager_id',
|
||||||
|
'employee_id',
|
||||||
|
'employee' => function () {
|
||||||
|
return [
|
||||||
|
"fio" => $this->employee->userCard->fio ?? $this->employee->username,
|
||||||
|
"avatar" => $this->employee->userCard->photo ?? '',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ActiveQuery
|
* @return ActiveQuery
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ use common\models\ProjectTaskCategory;
|
|||||||
use common\models\ProjectUser;
|
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\Project;
|
use frontend\modules\api\models\Project;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
@ -341,4 +342,43 @@ class ProjectController extends ApiController
|
|||||||
}
|
}
|
||||||
return $project;
|
return $project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @OA\Get(path="/project/my-employee",
|
||||||
|
* summary="Список Сотрудников текущего пользователя",
|
||||||
|
* description="Метод для получения списка сотрудников",
|
||||||
|
* security={
|
||||||
|
* {"bearerAuth": {}}
|
||||||
|
* },
|
||||||
|
* tags={"TaskManager"},
|
||||||
|
*
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Возвращает объект Менеджера",
|
||||||
|
* @OA\MediaType(
|
||||||
|
* mediaType="application/json",
|
||||||
|
* @OA\Schema(ref="#/components/schemas/ManagerEmployee"),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @return array|\yii\db\ActiveRecord
|
||||||
|
* @throws BadRequestHttpException
|
||||||
|
*/
|
||||||
|
public function actionMyEmployee()
|
||||||
|
{
|
||||||
|
$user_id = \Yii::$app->user->id;
|
||||||
|
if (!$user_id) {
|
||||||
|
throw new BadRequestHttpException(json_encode(['Пользователь не найден']));
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = Manager::find()->with(['managerEmployees'])->where(['user_id' => $user_id])->one();
|
||||||
|
|
||||||
|
if (!$model){
|
||||||
|
throw new BadRequestHttpException(json_encode(['Менеджер не найден']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
}
|
}
|
16
frontend/modules/api/models/Manager.php
Normal file
16
frontend/modules/api/models/Manager.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\modules\api\models;
|
||||||
|
|
||||||
|
class Manager extends \common\models\Manager
|
||||||
|
{
|
||||||
|
public function fields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id',
|
||||||
|
'user_id',
|
||||||
|
'managerEmployees'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
frontend/modules/api/models/ManagerEmployee.php
Normal file
59
frontend/modules/api/models/ManagerEmployee.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\modules\api\models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @OA\Schema(
|
||||||
|
* schema="ManagerEmployee",
|
||||||
|
* @OA\Property(
|
||||||
|
* property="id",
|
||||||
|
* type="int",
|
||||||
|
* example=95,
|
||||||
|
* description="Идентификатор задачи"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="user_id",
|
||||||
|
* type="int",
|
||||||
|
* example="19",
|
||||||
|
* description="Идентификатор пользователя"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="managerEmployees",
|
||||||
|
* ref="#/components/schemas/ManagerEmployees",
|
||||||
|
* ),
|
||||||
|
*)
|
||||||
|
*
|
||||||
|
* @OA\Schema(
|
||||||
|
* schema="ManagerEmployees",
|
||||||
|
* type="array",
|
||||||
|
* @OA\Items(
|
||||||
|
* type="object",
|
||||||
|
* @OA\Property(
|
||||||
|
* property="id",
|
||||||
|
* type="integer",
|
||||||
|
* example="1"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="manager_id",
|
||||||
|
* type="integer",
|
||||||
|
* example="1"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="employee_id",
|
||||||
|
* type="integer",
|
||||||
|
* example="19"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="employee",
|
||||||
|
* type="object",
|
||||||
|
* ref="#/components/schemas/ProjectTaskUsersShortExample",
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
*)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ManagerEmployee extends \common\models\ManagerEmployee
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user