2021-06-25 18:11:30 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace frontend\modules\api\controllers;
|
|
|
|
|
2023-04-13 01:21:53 +03:00
|
|
|
use common\models\UserCard;
|
2023-10-20 15:02:59 +03:00
|
|
|
use frontend\modules\api\services\ProfileService;
|
2022-10-19 15:28:09 +03:00
|
|
|
use yii\helpers\ArrayHelper;
|
2022-03-21 19:08:39 +03:00
|
|
|
use yii\web\ServerErrorHttpException;
|
2022-01-14 12:56:39 +03:00
|
|
|
|
2021-11-29 18:21:50 +03:00
|
|
|
class ProfileController extends ApiController
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2022-10-19 15:28:09 +03:00
|
|
|
|
|
|
|
public function behaviors(): array
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2022-10-19 15:28:09 +03:00
|
|
|
return ArrayHelper::merge(parent::behaviors(), [
|
|
|
|
|
|
|
|
'verbs' => [
|
|
|
|
'class' => \yii\filters\VerbFilter::class,
|
|
|
|
'actions' => [
|
2023-01-13 15:46:15 +03:00
|
|
|
'' => ['GET', 'HEAD', 'OPTIONS'],
|
2022-10-19 15:28:09 +03:00
|
|
|
'profile-with-report-permission' => ['post', 'patch'],
|
2023-04-13 01:09:35 +03:00
|
|
|
'get-main-data' => ['get'],
|
|
|
|
'positions-list' => ['get'],
|
2023-04-13 01:21:53 +03:00
|
|
|
'level-list' => ['get'],
|
2022-10-19 15:28:09 +03:00
|
|
|
],
|
|
|
|
]
|
|
|
|
]);
|
2021-06-25 18:11:30 +03:00
|
|
|
}
|
|
|
|
|
2023-10-20 15:02:59 +03:00
|
|
|
private ProfileService $profileService;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
$id,
|
|
|
|
$module,
|
|
|
|
ProfileService $profileService,
|
|
|
|
$config = []
|
|
|
|
)
|
|
|
|
{
|
|
|
|
$this->profileService = $profileService;
|
|
|
|
parent::__construct($id, $module, $config);
|
|
|
|
}
|
|
|
|
|
2022-10-19 15:28:09 +03:00
|
|
|
/**
|
2023-10-20 15:02:59 +03:00
|
|
|
* @param null $id
|
|
|
|
* @return array|null
|
2022-10-19 15:28:09 +03:00
|
|
|
*/
|
2022-03-21 19:08:39 +03:00
|
|
|
public function actionIndex($id = null): ?array
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2023-10-20 15:02:59 +03:00
|
|
|
return $this->profileService->getProfile($id, \Yii::$app->request->get());
|
2021-07-03 15:15:54 +03:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:56:21 +03:00
|
|
|
/**
|
2023-10-20 15:02:59 +03:00
|
|
|
* @param $id
|
|
|
|
* @return array|null
|
|
|
|
* @throws ServerErrorHttpException
|
2022-03-21 14:56:21 +03:00
|
|
|
*/
|
|
|
|
public function actionProfileWithReportPermission($id): ?array
|
2021-09-07 16:32:57 +03:00
|
|
|
{
|
2023-10-20 15:02:59 +03:00
|
|
|
return $this->profileService->getProfileWithReportPermission($id);
|
2021-09-07 16:32:57 +03:00
|
|
|
}
|
2022-03-21 19:08:39 +03:00
|
|
|
|
|
|
|
/**
|
2023-10-20 15:02:59 +03:00
|
|
|
* @param $user_id
|
|
|
|
* @return array
|
2022-03-21 19:08:39 +03:00
|
|
|
* @throws ServerErrorHttpException
|
|
|
|
*/
|
|
|
|
public function actionGetMainData($user_id): array
|
|
|
|
{
|
2023-10-20 15:02:59 +03:00
|
|
|
return $this->profileService->getMainData($user_id);
|
2022-03-21 19:08:39 +03:00
|
|
|
}
|
2022-12-27 11:45:28 +03:00
|
|
|
|
2023-10-20 15:02:59 +03:00
|
|
|
/**
|
|
|
|
* @param $card_id
|
|
|
|
* @return array
|
|
|
|
*/
|
2022-12-27 11:45:28 +03:00
|
|
|
public function actionPortfolioProjects($card_id): array
|
|
|
|
{
|
2023-10-20 15:02:59 +03:00
|
|
|
return $this->profileService->getPortfolioProjects($card_id);
|
2022-12-27 11:45:28 +03:00
|
|
|
}
|
2023-04-13 01:09:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Get(path="/profile/positions-list",
|
|
|
|
* summary="Список позиций",
|
|
|
|
* description="Получить список всех возможных позиций",
|
|
|
|
* tags={"Profile"},
|
|
|
|
* security={
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
* },
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Возвращает массив позиций",
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* @OA\Schema(ref="#/components/schemas/PositionsExample"),
|
|
|
|
* ),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function actionPositionsList(): array
|
|
|
|
{
|
2023-10-20 15:02:59 +03:00
|
|
|
return $this->profileService->getPositionsList();
|
2023-04-13 01:09:35 +03:00
|
|
|
}
|
2023-04-13 01:21:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Get(path="/profile/level-list",
|
|
|
|
* summary="Список уровней навыков",
|
|
|
|
* description="Получить список всех возможных уровней навыков",
|
|
|
|
* tags={"Profile"},
|
|
|
|
* security={
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
* },
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Возвращает массив позиций",
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* ),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function actionLevelList(): array
|
|
|
|
{
|
|
|
|
return UserCard::getLevelList();
|
|
|
|
}
|
2022-03-21 14:56:21 +03:00
|
|
|
}
|