From b170717c7b73a6e5d28c3474425a4fe2ce242e98 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Mon, 28 Nov 2022 23:14:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exceptions/EmqxSupportException.php | 10 ++++++++++ .../Controllers/Admin/DeviceController.php | 8 +++++++- app/Support/EmqxSupport.php | 6 +++++- resources/views/admin/device/index.blade.php | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 app/Exceptions/EmqxSupportException.php diff --git a/app/Exceptions/EmqxSupportException.php b/app/Exceptions/EmqxSupportException.php new file mode 100644 index 0000000..5e84011 --- /dev/null +++ b/app/Exceptions/EmqxSupportException.php @@ -0,0 +1,10 @@ +clients($request->all()); + $clients = $emqx->clients([ + 'clientid' => $request->client_id, + 'username' => $request->username, + 'page' => $request->page, + ]); + // dd($clients); return view('admin.device.index', compact('clients')); } diff --git a/app/Support/EmqxSupport.php b/app/Support/EmqxSupport.php index 4f40524..cda12c2 100644 --- a/app/Support/EmqxSupport.php +++ b/app/Support/EmqxSupport.php @@ -2,6 +2,7 @@ namespace App\Support; +use App\Exceptions\EmqxSupportException; use Illuminate\Http\Client\PendingRequest; use Illuminate\Support\Facades\Http; @@ -12,6 +13,9 @@ private function api(): PendingRequest return Http::baseUrl(config('emqx.api_url'))->withBasicAuth(config('emqx.api_key'), config('emqx.api_secret')); } + /** + * @throws EmqxSupportException + */ public function clients($params = []) { // merge params @@ -25,7 +29,7 @@ public function clients($params = []) if ($response->successful()) { return $response->json(); } else { - return false; + throw new EmqxSupportException('无法获取客户端列表。'); } } diff --git a/resources/views/admin/device/index.blade.php b/resources/views/admin/device/index.blade.php index b895d14..9aa3409 100644 --- a/resources/views/admin/device/index.blade.php +++ b/resources/views/admin/device/index.blade.php @@ -84,4 +84,22 @@ +
+
+ +
+
+ @endsection