From 9465f19479d19ffaed6e90b0f777cee0b75183e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Thu, 8 May 2025 14:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9B=A0=E4=B8=BA=20ArrHelper::getvalue()=20?= =?UTF-8?q?=E4=BC=A0=E5=8F=82=E4=B8=8D=E4=B8=A5=E8=B0=A8=E5=88=B0=E7=9A=84?= =?UTF-8?q?500=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/GetDeviceDetailV1Controller.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Server/application/cunkebao/controller/device/GetDeviceDetailV1Controller.php b/Server/application/cunkebao/controller/device/GetDeviceDetailV1Controller.php index 0cb0cd58..e09bdbae 100644 --- a/Server/application/cunkebao/controller/device/GetDeviceDetailV1Controller.php +++ b/Server/application/cunkebao/controller/device/GetDeviceDetailV1Controller.php @@ -34,7 +34,7 @@ class GetDeviceDetailV1Controller extends BaseController $hasPermission = DeviceUserModel::where($where)->count() > 0; if (!$hasPermission) { - throw new \Exception('您没有权限查看该设备', '403'); + throw new \Exception('您没有权限查看该设备', 403); } } @@ -67,8 +67,8 @@ class GetDeviceDetailV1Controller extends BaseController protected function getTaskConfig(int $deviceId): array { $where = [ - 'deviceId' => $deviceId, - 'companyId' => $this->getUserInfo('companyId'), + 'deviceId' => $deviceId, + 'companyId' => $this->getUserInfo('companyId'), ]; $conf = DeviceTaskconfModel::alias('c') @@ -78,9 +78,12 @@ class GetDeviceDetailV1Controller extends BaseController ->where($where) ->find(); - return $conf - ? $conf->toArray() - : ArrHelper::getValue([], 'autoAddFriend,autoReply,contentSync,aiChat', 0); + if (!is_null($conf)) { + return $conf->toArray(); + } + + // 未配置时赋予默认关闭的状态 + return ArrHelper::getValue('autoAddFriend,autoReply,contentSync,aiChat', [], 0); } /** @@ -131,7 +134,7 @@ class GetDeviceDetailV1Controller extends BaseController ->find($id); if (empty($device)) { - throw new \Exception('设备不存在', '404'); + throw new \Exception('设备不存在', 404); } $device['battery'] = $this->parseExtraForBattery($device['extra']);