From 33e0d4f4142486bbd5a049f3349fdc0270e0c37e Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 24 Jun 2026 10:20:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E9=94=99=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/ParkingElectronicMapController.php | 9 ++++++++- app/Services/ParkingVipListService.php | 9 +++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Admin/ParkingElectronicMapController.php b/app/Http/Controllers/Admin/ParkingElectronicMapController.php index cf78010..7a59858 100644 --- a/app/Http/Controllers/Admin/ParkingElectronicMapController.php +++ b/app/Http/Controllers/Admin/ParkingElectronicMapController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Admin; +use App\Exceptions\CustomException; use App\Services\AdminFloorService; use App\Services\ApiResponseService; use App\Services\ParkingElectronicMapService; @@ -87,6 +88,8 @@ class ParkingElectronicMapController extends BaseController 'parking_space_list' => $list ]; return $this->responseService->success($data); + } catch (ValidationException $e) { + throw $e; } catch (Exception $e) { $m_prefix = __('exception.exception_handler.resource'); return $this->responseService->systemError( @@ -128,13 +131,15 @@ class ParkingElectronicMapController extends BaseController $data = $request->all(); $saveData = $data['saveData'] ?? []; if (empty($saveData)) { - throw new Exception(__('validation.map.d_empty')); + throw new CustomException(__('validation.map.d_empty')); } foreach ($saveData as $item) { $this->saveValidator($item, 1); } $this->service->saveModel($saveData); return $this->responseService->success([], __('admin.save_succeeded')); + } catch (CustomException|ValidationException $e) { + throw $e; } catch (Exception $e) { $m_prefix = __('admin.save_failed'); return $this->responseService->systemError( @@ -151,6 +156,8 @@ class ParkingElectronicMapController extends BaseController $this->saveValidator($data); $list = $this->service->getList($data); return $this->responseService->success($list); + } catch (ValidationException $e) { + throw $e; } catch (Exception $e) { $m_prefix = __('exception.exception_handler.resource'); return $this->responseService->systemError( diff --git a/app/Services/ParkingVipListService.php b/app/Services/ParkingVipListService.php index d3ddbb5..dd0cde8 100644 --- a/app/Services/ParkingVipListService.php +++ b/app/Services/ParkingVipListService.php @@ -2,12 +2,9 @@ namespace App\Services; -use App\Models\ParkingLicensePlate; -use App\Models\ParkingSpaceType; +use App\Exceptions\CustomException; use App\Models\ParkingVipList; use Exception; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; @@ -32,7 +29,7 @@ class ParkingVipListService /** * @param array $data - * @throws Exception + * @throws CustomException */ public function createModel(array $data) { @@ -45,7 +42,7 @@ class ParkingVipListService if (ParkingVipList::query()->where('license_id', $license_id) ->exists() ) { - throw new Exception( + throw new CustomException( __('service.admin_vip_list.license_exists') ); }