search result in Request
This commit is contained in:
parent
4c85beb0ca
commit
d2de940aa3
@ -57,7 +57,7 @@ class RequestController extends Controller
|
|||||||
{
|
{
|
||||||
$res = RequestService::run($id)->getById();
|
$res = RequestService::run($id)->getById();
|
||||||
|
|
||||||
$search = RequestService::run($id)->search(3);
|
$search = RequestService::run($id)->search(3)->all();
|
||||||
|
|
||||||
$searchDataProvider = new ArrayDataProvider([
|
$searchDataProvider = new ArrayDataProvider([
|
||||||
'allModels' => $search,
|
'allModels' => $search,
|
||||||
|
@ -24,6 +24,7 @@ use yii\db\Expression;
|
|||||||
* @property int $specialist_count
|
* @property int $specialist_count
|
||||||
* @property int $status
|
* @property int $status
|
||||||
* @property int $result_count
|
* @property int $result_count
|
||||||
|
* @property array $result_profiles
|
||||||
*/
|
*/
|
||||||
class Request extends \yii\db\ActiveRecord
|
class Request extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -32,6 +33,8 @@ class Request extends \yii\db\ActiveRecord
|
|||||||
|
|
||||||
public int $result_count = 0;
|
public int $result_count = 0;
|
||||||
|
|
||||||
|
public array $result_profiles = [];
|
||||||
|
|
||||||
public array $skills = [];
|
public array $skills = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,6 +80,7 @@ class Request extends \yii\db\ActiveRecord
|
|||||||
'position',
|
'position',
|
||||||
'skills',
|
'skills',
|
||||||
'result_count',
|
'result_count',
|
||||||
|
'result_profiles',
|
||||||
'level' => function (Request $model) {
|
'level' => function (Request $model) {
|
||||||
return UserCard::getLevelList()[$model->knowledge_level_id];
|
return UserCard::getLevelList()[$model->knowledge_level_id];
|
||||||
},
|
},
|
||||||
|
@ -35,6 +35,16 @@ class RequestService
|
|||||||
*/
|
*/
|
||||||
public bool $isLoad = false;
|
public bool $isLoad = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public int $resultCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $resultProfiles = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -235,9 +245,9 @@ class RequestService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $searchDepth
|
* @param int $searchDepth
|
||||||
* @return array|int
|
* @return RequestService
|
||||||
*/
|
*/
|
||||||
public function search(int $searchDepth = 0)
|
public function search(int $searchDepth = 0):RequestService
|
||||||
{
|
{
|
||||||
$cards = $this->_search();
|
$cards = $this->_search();
|
||||||
$res = [];
|
$res = [];
|
||||||
@ -254,14 +264,10 @@ class RequestService
|
|||||||
$res = $this->checkLevel(false)->checkPosition(false)->setSkillsFullEntry(false)->useExcludePool()->_search();
|
$res = $this->checkLevel(false)->checkPosition(false)->setSkillsFullEntry(false)->useExcludePool()->_search();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->returnCount) {
|
$this->resultProfiles = array_merge($cards, $res);
|
||||||
if (is_array($res)) {
|
$this->resultCount = count($this->resultProfiles);
|
||||||
return $cards;
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge($cards, $res);
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,13 +328,21 @@ class RequestService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $value
|
* @param bool $value
|
||||||
* @return $this
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count(bool $value = true): RequestService
|
public function count(bool $value = true): int
|
||||||
{
|
{
|
||||||
$this->returnCount = $value;
|
$this->returnCount = $value;
|
||||||
|
|
||||||
return $this;
|
return $this->resultCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function all(): array
|
||||||
|
{
|
||||||
|
return $this->resultProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function q()
|
public static function q()
|
||||||
|
@ -65,15 +65,18 @@ class RequestController extends ApiController
|
|||||||
throw new NotFoundHttpException('Incorrect request ID');
|
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');
|
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);
|
$requests = RequestService::run()->getByUserId($user_id);
|
||||||
|
|
||||||
foreach ($requests as $request) {
|
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;
|
return $requests;
|
||||||
|
@ -94,6 +94,10 @@ namespace frontend\modules\api\models;
|
|||||||
* example="Middle",
|
* example="Middle",
|
||||||
* description="Текстовое наименование уровня знаний"
|
* description="Текстовое наименование уровня знаний"
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="result_profiles",
|
||||||
|
* ref="#/components/schemas/RequestsProfileSearchExample",
|
||||||
|
* ),
|
||||||
*)
|
*)
|
||||||
*
|
*
|
||||||
* @OA\Schema(
|
* @OA\Schema(
|
||||||
@ -103,6 +107,35 @@ namespace frontend\modules\api\models;
|
|||||||
* ref="#/components/schemas/Request",
|
* 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
|
class Request extends \common\models\Request
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user