Browse Source

修改报错异常

master
wanghongjun 3 days ago
parent
commit
33e0d4f414
  1. 9
      app/Http/Controllers/Admin/ParkingElectronicMapController.php
  2. 9
      app/Services/ParkingVipListService.php

9
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(

9
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')
);
}

Loading…
Cancel
Save