From 9246bdd00cb7261e86b0cc489034da8330cd10a5 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 23 Dec 2019 10:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E5=90=88=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=8E=B7=E5=8F=96=E9=94=99=E8=AF=AF=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/services/GroupDataService.php | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/crmeb/crmeb/services/GroupDataService.php b/crmeb/crmeb/services/GroupDataService.php index 3705670d..8a6754e6 100644 --- a/crmeb/crmeb/services/GroupDataService.php +++ b/crmeb/crmeb/services/GroupDataService.php @@ -24,10 +24,14 @@ class GroupDataService public static function getGroupData(string $config_name, $limit = 0, bool $isCaChe = false): array { $callable = function () use ($config_name, $limit) { - $data = SystemGroupData::getGroupData($config_name, $limit); - if (is_object($data)) - $data = $data->toArray(); - return $data; + try { + $data = SystemGroupData::getGroupData($config_name, $limit); + if (is_object($data)) + $data = $data->toArray(); + return $data; + } catch (\Exception $e) { + return []; + } }; try { $cacheName = $limit ? "group_data_{$config_name}_{$limit}" : "data_{$config_name}"; @@ -38,11 +42,7 @@ class GroupDataService return CacheService::get($cacheName, $callable); } catch (\Throwable $e) { - try { - return $callable(); - } catch (\Exception $e) { - return []; - } + return $callable(); } } @@ -56,10 +56,14 @@ class GroupDataService public static function getData(string $config_name, int $limit = 0, bool $isCaChe = false): array { $callable = function () use ($config_name, $limit) { - $data = SystemGroupData::getAllValue($config_name, $limit); - if (is_object($data)) - $data = $data->toArray(); - return $data; + try { + $data = SystemGroupData::getAllValue($config_name, $limit); + if (is_object($data)) + $data = $data->toArray(); + return $data; + } catch (\Exception $e) { + return []; + } }; try { $cacheName = $limit ? "data_{$config_name}_{$limit}" : "data_{$config_name}"; @@ -70,11 +74,7 @@ class GroupDataService return CacheService::get($cacheName, $callable); } catch (\Throwable $e) { - try { - return $callable(); - } catch (\Exception $e) { - return []; - } + return $callable(); } } @@ -87,10 +87,14 @@ class GroupDataService public static function getDataNumber(int $id, bool $isCaChe = false): array { $callable = function () use ($id) { - $data = SystemGroupData::getDateValue($id); - if (is_object($data)) - $data = $data->toArray(); - return $data; + try { + $data = SystemGroupData::getDateValue($id); + if (is_object($data)) + $data = $data->toArray(); + return $data; + } catch (\Exception $e) { + return []; + } }; try { $cacheName = "data_number_{$id}"; @@ -101,11 +105,7 @@ class GroupDataService return CacheService::get($cacheName, $callable); } catch (\Throwable $e) { - try { - return $callable(); - } catch (\Exception $e) { - return []; - } + return $callable(); } } } \ No newline at end of file