Skip to content

Commit

Permalink
- 优化空数据返回
Browse files Browse the repository at this point in the history
  • Loading branch information
dtapps committed Apr 5, 2020
1 parent ed7a1bc commit 7f51e6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function getList($page = 1, $limit = 15, $search = '')
$result = $this->HttpPostCookie($url, $p_data);
//解析JSON数据
$data = json_decode($result, true);
if (empty($data['data'])) $data['data'] = [];
if (empty($data['page'])) $data['page'] = 0;
return [
'data' => $data['data'],
'count' => $this->getCountData($data['page'])
Expand Down
4 changes: 4 additions & 0 deletions src/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function getList($page = 1, $limit = 10)
$result = $this->HttpPostCookie($url, $p_data);
//解析JSON数据
$data = json_decode($result, true);
if (empty($data['data'])) $data['data'] = [];
if (empty($data['page'])) $data['page'] = 0;
return [
'data' => $data['data'],
'count' => $this->getCountData($data['page'])
Expand All @@ -57,6 +59,8 @@ public function getLog($page = 1, $limit = 10)
$result = $this->HttpPostCookie($url, $p_data);
//解析JSON数据
$data = json_decode($result, true);
if (empty($data['data'])) $data['data'] = [];
if (empty($data['page'])) $data['page'] = 0;
return [
'data' => $data['data'],
'count' => $this->getCountData($data['page'])
Expand Down
2 changes: 2 additions & 0 deletions src/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function getList($page = 1, $limit = 15, $search = '', $type = -1)
$result = $this->HttpPostCookie($url, $p_data);
//解析JSON数据
$data = json_decode($result, true);
if (empty($data['data'])) $data['data'] = [];
if (empty($data['page'])) $data['page'] = 0;
return [
'data' => $data['data'],
'count' => $this->getCountData($data['page'])
Expand Down

0 comments on commit 7f51e6c

Please sign in to comment.