diff --git a/common/services/ProfileService.php b/common/services/ProfileService.php index 4e13366..fc47886 100644 --- a/common/services/ProfileService.php +++ b/common/services/ProfileService.php @@ -8,13 +8,32 @@ use common\models\UserCard; use frontend\modules\api\models\ProfileSearchForm; use Yii; use yii\web\BadRequestHttpException; +use yii\web\ServerErrorHttpException; class ProfileService { + /** + * @throws ServerErrorHttpException + */ + public static function getMainData($user_id): array + { + $userCard = UserCard::findOne(['id_user' => $user_id]); + if (empty($userCard)) { + throw new ServerErrorHttpException(json_encode($userCard->errors)); + } + return array('fio' => $userCard->fio, + 'photo' => $userCard->photo, + 'gender' => $userCard->gender, + 'level' => $userCard->level, + 'years_of_exp' => $userCard->years_of_exp, + 'specification' => $userCard->specification, + 'position_name' => $userCard->position->name); + } + /** * @throws BadRequestHttpException */ - public static function getProfile($id, $request): ?array + public static function getProfile($id, $request)//: ?array { $searchModel = new ProfileSearchForm(); $searchModel->attributes = $request; diff --git a/common/services/UserCardService.php b/common/services/UserCardService.php deleted file mode 100644 index bb743c2..0000000 --- a/common/services/UserCardService.php +++ /dev/null @@ -1,27 +0,0 @@ - $user_id]); - if (empty($userCard)) { - throw new ServerErrorHttpException(json_encode($userCard->errors)); - } - return array('fio' => $userCard->fio, - 'photo' => $userCard->photo, - 'gender' => $userCard->gender, - 'level' => $userCard->level, - 'years_of_exp' => $userCard->years_of_exp, - 'specification' => $userCard->specification, - 'position_name' => $userCard->position->name); - } -} \ No newline at end of file diff --git a/docs/api/profile.md b/docs/api/profile.md index 3c69b84..f795fa9 100644 --- a/docs/api/profile.md +++ b/docs/api/profile.md @@ -1,4 +1,4 @@ -## Профиль +# Профиль ## Методы
+ profile/get-main-data + | ++ Получить получить основные данные профиля + | +
+ Требуемые параметры: +
++ Параметры + | ++ Значение + | +
---|---|
+ user_id + | ++ Id профиля пользователя + | +
+ Возвращает объект Пользователь.
+ Каждый объект Пользователь имеет такой вид:
+
+ Возвращаемые параметры: +
++ Параметры + | ++ Значение + | +
---|---|
+ fio + | ++ ФИО + | +
+ photo + | ++ Ссылка на фото + | +
+ gender + | ++ Пол + | +
+ level + | ++ Уровень + | +
+ years_of_exp + | ++ Лет опыта + | +
+ position_name + | ++ Должность + | +