2023-11-07 15:42:15 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace frontend\modules\api\controllers;
|
|
|
|
|
|
2023-11-22 12:42:36 +03:00
|
|
|
|
use frontend\modules\api\models\resume\forms\ChangeResumeForm;
|
2023-11-07 15:42:15 +03:00
|
|
|
|
use frontend\modules\api\models\resume\Resume;
|
2023-11-22 12:42:36 +03:00
|
|
|
|
use frontend\modules\api\services\ResumeService;
|
2023-11-07 15:42:15 +03:00
|
|
|
|
use Yii;
|
2023-11-22 12:42:36 +03:00
|
|
|
|
use yii\web\BadRequestHttpException;
|
2023-11-07 15:42:15 +03:00
|
|
|
|
|
|
|
|
|
class ResumeController extends ApiController
|
|
|
|
|
{
|
2023-11-22 12:42:36 +03:00
|
|
|
|
public ResumeService $resumeService;
|
|
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
$id,
|
|
|
|
|
$module,
|
|
|
|
|
ResumeService $resumeService,
|
|
|
|
|
$config = []
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
$this->resumeService = $resumeService;
|
|
|
|
|
parent::__construct($id, $module, $config);
|
|
|
|
|
}
|
2023-11-07 15:42:15 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(path="/resume",
|
|
|
|
|
* summary="Резюме пользователя",
|
|
|
|
|
* description="Получение резюме пользователя",
|
|
|
|
|
* security={
|
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
|
* },
|
|
|
|
|
* tags={"Resume"},
|
|
|
|
|
* @OA\Parameter(
|
|
|
|
|
* name="userId",
|
2023-11-07 15:46:19 +03:00
|
|
|
|
* description="Метод для получение резюме. userId - обязателен, в случае его отсудствия будет возвращено резюме текущего пользователя",
|
2023-11-07 15:42:15 +03:00
|
|
|
|
* in="query",
|
|
|
|
|
* required=false,
|
|
|
|
|
* @OA\Schema(
|
|
|
|
|
* type="integer",
|
|
|
|
|
* )
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response=200,
|
|
|
|
|
* description="Возвращает объект Резюме",
|
|
|
|
|
* @OA\MediaType(
|
|
|
|
|
* mediaType="application/json",
|
|
|
|
|
* @OA\Schema(ref="#/components/schemas/Resume"),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* )
|
|
|
|
|
*
|
|
|
|
|
* @param int|null $userId
|
|
|
|
|
* @return Resume|null
|
|
|
|
|
*/
|
|
|
|
|
public function actionIndex(int $userId = null): ?Resume
|
|
|
|
|
{
|
|
|
|
|
return Resume::findOne($userId ?? Yii::$app->user->identity->id);
|
|
|
|
|
}
|
2023-11-22 12:42:36 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @OA\Put(path="/resume/edit-skills",
|
|
|
|
|
* summary="Изменить скилы",
|
|
|
|
|
* description="Метод полностью удалит старые скилы и используя переданые id скилов запишет новые",
|
|
|
|
|
* security={
|
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
|
* },
|
|
|
|
|
* tags={"Resume"},
|
|
|
|
|
*
|
|
|
|
|
* @OA\RequestBody(
|
|
|
|
|
* @OA\MediaType(
|
|
|
|
|
* mediaType="json",
|
|
|
|
|
* @OA\Schema(
|
|
|
|
|
* required={"UserCard"},
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="UserCard",
|
|
|
|
|
* type="object",
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="skill",
|
|
|
|
|
* type="array",
|
|
|
|
|
* @OA\Items(
|
|
|
|
|
* type="integer",
|
|
|
|
|
* example={1,2,3,4}
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response=200,
|
|
|
|
|
* description="Возвращает сообщение об успехе",
|
|
|
|
|
* ),
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*
|
|
|
|
|
* @return array|ChangeResumeForm
|
|
|
|
|
* @throws BadRequestHttpException
|
|
|
|
|
*/
|
|
|
|
|
public function actionEditSkills()
|
|
|
|
|
{
|
|
|
|
|
return $this->resumeService->editSkills(Yii::$app->request->post(), Yii::$app->user->identity->getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @OA\Put(path="/resume/edit-text",
|
|
|
|
|
* summary="Изменить резюме",
|
|
|
|
|
* description="Метод для изменения текста резюме",
|
|
|
|
|
* security={
|
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
|
* },
|
|
|
|
|
* tags={"Resume"},
|
|
|
|
|
*
|
|
|
|
|
* @OA\RequestBody(
|
|
|
|
|
* @OA\MediaType(
|
|
|
|
|
* mediaType="application/x-www-form-urlencoded",
|
|
|
|
|
* @OA\Schema(
|
|
|
|
|
* required={"resume"},
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="resume",
|
|
|
|
|
* type="string",
|
|
|
|
|
* description="Текст резюме",
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response=200,
|
|
|
|
|
* description="Возвращает сообщение об успехе",
|
|
|
|
|
* ),
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*
|
|
|
|
|
* @return array|ChangeResumeForm
|
|
|
|
|
* @throws BadRequestHttpException
|
|
|
|
|
*/
|
|
|
|
|
public function actionEditText(): ChangeResumeForm|array
|
|
|
|
|
{
|
|
|
|
|
return $this->resumeService->editText(Yii::$app->request->post(), Yii::$app->user->identity->getId());
|
|
|
|
|
}
|
2023-11-07 15:42:15 +03:00
|
|
|
|
}
|