add resume request

This commit is contained in:
iIronside 2023-11-07 15:42:15 +03:00
parent df05e0421c
commit 44cfe842d5
3 changed files with 107 additions and 3 deletions

View File

@ -2,14 +2,11 @@
namespace common\models; namespace common\models;
use common\classes\Debug;
use Exception; use Exception;
use phpDocumentor\Reflection\Types\This;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
use yii\db\Expression; use yii\db\Expression;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
/** /**
@ -45,6 +42,7 @@ use yii\helpers\ArrayHelper;
* *
* @property FieldsValue[] $fieldsValues * @property FieldsValue[] $fieldsValues
* @property ProjectUser[] $projectUsers * @property ProjectUser[] $projectUsers
* @property CardSkill[] $skillValues
* @property ResumeTemplate $resumeTemplate * @property ResumeTemplate $resumeTemplate
* @property Position $position * @property Position $position
* @property Status $status0 * @property Status $status0
@ -246,6 +244,13 @@ class UserCard extends \yii\db\ActiveRecord
return $this->hasMany(CardSkill::class, ['card_id' => 'id'])->with('skill'); return $this->hasMany(CardSkill::class, ['card_id' => 'id'])->with('skill');
} }
public function getSkillsName()
{
return $this->getSkillValues()
->leftJoin('skill', 'card_skill.skill_id = skill.id')
->select('skill.name')->column();
}
public static function getNameSkills() public static function getNameSkills()
{ {
return ArrayHelper::map(Skill::find()->all(), 'id', 'name'); return ArrayHelper::map(Skill::find()->all(), 'id', 'name');

View File

@ -0,0 +1,45 @@
<?php
namespace frontend\modules\api\controllers;
use frontend\modules\api\models\resume\Resume;
use Yii;
class ResumeController extends ApiController
{
/**
* @OA\Get(path="/resume",
* summary="Резюме пользователя",
* description="Получение резюме пользователя",
* security={
* {"bearerAuth": {}}
* },
* tags={"Resume"},
* @OA\Parameter(
* name="userId",
* description="Метод для получение резюме",
* 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);
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace frontend\modules\api\models\resume;
use yii\helpers\ArrayHelper;
/**
*
* @OA\Schema(
* schema="Resume",
* @OA\Property(
* property="stack",
* type="array",
* @OA\Items(
* type="string",
* ),
* example="[Yii2,Vue]",
* description="Основной стек"
* ),
* @OA\Property(
* property="resume",
* type="string",
* example="Резюме",
* description="Тело резюме в HTML разметке"
* ),
*)
*
* @OA\Schema(
* schema="ResumeExample",
* type="array",
* @OA\Items(
* ref="#/components/schemas/Resume",
* ),
*)
*/
class Resume extends \common\models\User
{
/**
* @return string[]
*/
public function fields(): array
{
return [
'stack' => function() {
return $this->userCard->getSkillsName();
},
'resume' => function () {
return $this->userCard->vc_text;
},
];
}
}