search result in Request

This commit is contained in:
2023-04-18 17:12:06 +03:00
parent 4c85beb0ca
commit d2de940aa3
5 changed files with 74 additions and 18 deletions

View File

@ -65,15 +65,18 @@ class RequestController extends ApiController
throw new NotFoundHttpException('Incorrect request ID');
}
$request = RequestService::run($request_id)->getById();
$requestService = RequestService::run($request_id);
$model = $requestService->getById();
if (empty($request)) {
if (empty($model)) {
throw new NotFoundHttpException('The request does not exist');
}
$request->result_count = RequestService::run($request_id)->count()->search($search_depth);
$model->result_count = $requestService->search($search_depth)->count();
$model->result_profiles = $requestService->all();
return $request;
return $model;
}
/**
@ -125,7 +128,9 @@ class RequestController extends ApiController
$requests = RequestService::run()->getByUserId($user_id);
foreach ($requests as $request) {
$request->result_count = RequestService::run($request->id)->count()->search($search_depth);
$requestService = RequestService::run($request->id);
$request->result_count = $requestService->search($search_depth)->count();
$request->result_profiles = $requestService->all();
}
return $requests;

View File

@ -94,6 +94,10 @@ namespace frontend\modules\api\models;
* example="Middle",
* description="Текстовое наименование уровня знаний"
* ),
* @OA\Property(
* property="result_profiles",
* ref="#/components/schemas/RequestsProfileSearchExample",
* ),
*)
*
* @OA\Schema(
@ -103,6 +107,35 @@ namespace frontend\modules\api\models;
* ref="#/components/schemas/Request",
* ),
*)
*
* @OA\Schema(
* schema="RequestsProfileSearchExample",
* type="array",
* example={
* {"id": 23, "fio": "Иванов Иван Иванович", "position_id": "1", "skill_id": "1"},
* {"id": 24, "fio": "Петров Петр Петрович", "position_id": "2", "skill_id": "1"}
* },
* @OA\Items(
* type="object",
* @OA\Property(
* property="id",
* type="integer",
* ),
* @OA\Property(
* property="fio",
* type="string",
* ),
* @OA\Property(
* property="position_id",
* type="integer",
* ),
* @OA\Property(
* property="skill_id",
* type="integer",
* ),
* ),
*)
*
*/
class Request extends \common\models\Request
{