guild/frontend/modules/api/controllers/ProfileController.php

85 lines
2.2 KiB
PHP
Raw Normal View History

2021-06-25 18:11:30 +03:00
<?php
namespace frontend\modules\api\controllers;
use common\services\ProfileService;
use yii\helpers\ArrayHelper;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;
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
{
public function behaviors(): array
2021-06-25 18:11:30 +03:00
{
return ArrayHelper::merge(parent::behaviors(), [
'verbs' => [
'class' => \yii\filters\VerbFilter::class,
'actions' => [
'' => ['GET', 'HEAD', 'OPTIONS'],
'profile-with-report-permission' => ['post', 'patch'],
'get-main-data' => ['get'],
'positions-list' => ['get'],
],
]
]);
2021-06-25 18:11:30 +03:00
}
/**
* @throws NotFoundHttpException
*/
public function actionIndex($id = null): ?array
2021-06-25 18:11:30 +03:00
{
return ProfileService::getProfile($id, \Yii::$app->request->get());
2021-07-03 15:15:54 +03:00
}
2022-03-21 14:56:21 +03:00
/**
* @throws BadRequestHttpException
*/
public function actionProfileWithReportPermission($id): ?array
2021-09-07 16:32:57 +03:00
{
2022-03-21 14:56:21 +03:00
return ProfileService::getProfileWithReportPermission($id);
2021-09-07 16:32:57 +03:00
}
/**
* @throws ServerErrorHttpException
*/
public function actionGetMainData($user_id): array
{
return ProfileService::getMainData($user_id);
}
2022-12-27 11:45:28 +03:00
public function actionPortfolioProjects($card_id): array
{
return ProfileService::getPortfolioProjects($card_id);
}
/**
*
* @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
{
return ProfileService::getPositionsList();
}
2022-03-21 14:56:21 +03:00
}