|
|
@ -6,7 +6,7 @@ use App\Models\ParkingCamera; |
|
|
use App\Services\ParkingCameraService; |
|
|
use App\Services\ParkingCameraService; |
|
|
use Illuminate\Http\JsonResponse; |
|
|
use Illuminate\Http\JsonResponse; |
|
|
use Illuminate\Http\Request; |
|
|
use Illuminate\Http\Request; |
|
|
use Illuminate\Support\Facades\Cache; |
|
|
use Illuminate\Support\Facades\Redis; |
|
|
|
|
|
|
|
|
class CameraApiController extends BaseController |
|
|
class CameraApiController extends BaseController |
|
|
{ |
|
|
{ |
|
|
@ -28,6 +28,7 @@ class CameraApiController extends BaseController |
|
|
$data = ParkingCamera::query()->select(['id', 'camera_ip', 'status']) |
|
|
$data = ParkingCamera::query()->select(['id', 'camera_ip', 'status']) |
|
|
->get() |
|
|
->get() |
|
|
->toArray(); |
|
|
->toArray(); |
|
|
|
|
|
Redis::set('camera_body', json_encode($data), 300); |
|
|
return $this->responseService->success(['list' => $data]); |
|
|
return $this->responseService->success(['list' => $data]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -46,12 +47,12 @@ class CameraApiController extends BaseController |
|
|
|
|
|
|
|
|
public function getCameraBody(): JsonResponse |
|
|
public function getCameraBody(): JsonResponse |
|
|
{ |
|
|
{ |
|
|
$body = Cache::get('camera_body'); |
|
|
$body = Redis::get('camera_body'); |
|
|
if (!$body) { |
|
|
if (!$body) { |
|
|
return $this->responseService->error('empty'); |
|
|
return $this->responseService->error('empty'); |
|
|
} else { |
|
|
} else { |
|
|
$bodyArr = json_decode($body); |
|
|
$bodyArr = json_decode($body); |
|
|
Cache::delete('camera_body'); |
|
|
Redis::delete('camera_body'); |
|
|
} |
|
|
} |
|
|
return $this->responseService->success($bodyArr, 'SUCCESS'); |
|
|
return $this->responseService->success($bodyArr, 'SUCCESS'); |
|
|
} |
|
|
} |
|
|
|