Browse Source

清除全部接口

master
wanghongjun 4 days ago
parent
commit
81d008654f
  1. 20
      app/Http/Controllers/Admin/ParkingInformationController.php
  2. 22
      app/Services/ParkingInformationService.php
  3. 3
      resources/lang/zh-CN/log.php
  4. 1
      routes/admin/api.php

20
app/Http/Controllers/Admin/ParkingInformationController.php

@ -210,6 +210,24 @@ class ParkingInformationController extends BaseController
}
}
public function clear(): JsonResponse
{
try {
$this->service->clearModel();
return $this->responseService->success(
null,
__('admin.delete_succeeded')
);
} catch (ValidationException|CustomException $e) {
throw $e;
} catch (Exception $e) {
return $this->responseService->systemError(
__('exception.license_plate.destroy_failed') . ':'
. $e->getMessage()
);
}
}
/**
* @return JsonResponse
* @throws InvalidArgumentException
@ -218,7 +236,7 @@ class ParkingInformationController extends BaseController
{
try {
return $this->responseService->success(
$this->methodShow('information')
$this->methodShow('information', ['clear']),
);
} catch (Exception $e) {
return $this->responseService->systemError(

22
app/Services/ParkingInformationService.php

@ -149,4 +149,26 @@ class ParkingInformationService extends BaseService
}
}
public function clearModel(): bool
{
try {
DB::beginTransaction();
$data = ParkingInformation::query()->get()->toArray();
$this->logService->logDeletedData(
(new ParkingInformation()),
'parking_information.clear',
$data
);
ParkingInformation::query()->delete();
DB::commit();
return true;
} catch (Exception $e) {
DB::rollBack();
throw $e;
}
}
}

3
resources/lang/zh-CN/log.php

@ -57,6 +57,7 @@ return [
],
'parking_information' => [
'create' => '创建车位资讯',
'delete' => '更新车位资讯'
'delete' => '更新车位资讯',
'clear' => '清除车位资讯'
]
];

1
routes/admin/api.php

@ -79,6 +79,7 @@ Route::group(['prefix' => 'admin'], function () {
Route::get('/information/search', [ParkingInformationController::class, 'search']);
Route::post('/information', [ParkingInformationController::class, 'store']);
Route::delete('/information/{id}', [ParkingInformationController::class, 'destroy']);
Route::get('/information/clear', [ParkingInformationController::class, 'clear']);
Route::get('/information/rule', [ParkingInformationController::class, 'rule']);
// VIP名单

Loading…
Cancel
Save