From 34d75003753a2260dff5594e47518e6e3f5c1426 Mon Sep 17 00:00:00 2001 From: kyoya0819 Date: Fri, 30 Aug 2024 06:51:42 +0900 Subject: [PATCH] =?UTF-8?q?/api/company/list=E3=82=92GET=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Company/ListController.php | 15 ++++++++----- .../Api/Company/List/InvokeRequest.php | 22 ------------------- backend/routes/api.php | 2 +- 3 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 backend/app/Http/Requests/Api/Company/List/InvokeRequest.php diff --git a/backend/app/Http/Controllers/Api/Company/ListController.php b/backend/app/Http/Controllers/Api/Company/ListController.php index b51b22f..edcab12 100644 --- a/backend/app/Http/Controllers/Api/Company/ListController.php +++ b/backend/app/Http/Controllers/Api/Company/ListController.php @@ -3,21 +3,26 @@ namespace App\Http\Controllers\Api\Company; use App\Http\Controllers\Controller; -use App\Http\Requests\Api\Company\List\InvokeRequest; use App\Models\Company; use App\UseCases\Company\ListFilterByIndustryIds; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; class ListController extends Controller { /** - * @param InvokeRequest $request + * @param Request $request * @return JsonResponse */ - public function __invoke(InvokeRequest $request): JsonResponse + public function __invoke(Request $request): JsonResponse { - /* @var int[] $industry_ids */ - $industry_ids = $request->validated()['industry_ids']; + $industry_ids_raw = $request->query("industry_ids"); + if ($industry_ids_raw === null) + return response()->json(); + + $industry_ids = is_array($industry_ids_raw) + ? array_map(fn ($industry_id) => (int) $industry_id, $industry_ids_raw) + : [(int) $industry_ids_raw]; $companies = ListFilterByIndustryIds::run($industry_ids); diff --git a/backend/app/Http/Requests/Api/Company/List/InvokeRequest.php b/backend/app/Http/Requests/Api/Company/List/InvokeRequest.php deleted file mode 100644 index 9dcdb39..0000000 --- a/backend/app/Http/Requests/Api/Company/List/InvokeRequest.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - public function rules(): array - { - return [ - "industry_ids" => ["required", "array"], - "industry_ids.*" => ["integer", "min:1", "max:16"], - ]; - } -} diff --git a/backend/routes/api.php b/backend/routes/api.php index 9608cf6..4be70b9 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -15,5 +15,5 @@ Route::post("/press-release/view", PressRelease\ViewController::class); Route::get("/press-release/recommend", PressRelease\RecommendController::class); - Route::post("/company/list", Company\ListController::class); + Route::get("/company/list", Company\ListController::class); }); \ No newline at end of file