diff --git a/src/HttpController/Admin/AdminTrait.php b/src/HttpController/Admin/AdminTrait.php index 9d65cbf..b9bc157 100644 --- a/src/HttpController/Admin/AdminTrait.php +++ b/src/HttpController/Admin/AdminTrait.php @@ -22,13 +22,13 @@ protected function __search() return $this->_search($where); } - protected function __after_index($items, $total) + protected function __after_index($items = [], $total = 0, $summer = []) { foreach ($items as &$value) { unset($value['password']); $value->relation; } - return parent::__after_index($items, $total); + return parent::__after_index($items, $total, $summer); } /** diff --git a/src/HttpController/Admin/AuthTrait.php b/src/HttpController/Admin/AuthTrait.php index c6f68d4..771549f 100644 --- a/src/HttpController/Admin/AuthTrait.php +++ b/src/HttpController/Admin/AuthTrait.php @@ -354,7 +354,7 @@ public function _index($return = false) return $return ? $data : $this->success($data); } - protected function __after_index($items, $total, $summer = []) + protected function __after_index($items = [], $total = 0, $summer = []) { return [config('fetchSetting.listField') => $items, config('fetchSetting.totalField') => $total] + ($summer ? [config('fetchSetting.footerField') => $summer] : []); } @@ -418,7 +418,7 @@ public function export() // todo 希望优化为fetch模式 $items = $this->Model->all($where); - $data = $this->__after_index($items, 0)[config('fetchSetting.listField')]; + $data = $this->__after_index($items)[config('fetchSetting.listField')]; // 是否需要合并合计行,如需合并,data为索引数组,为空字段需要占位 diff --git a/src/HttpController/Admin/HttpTrackerTrait.php b/src/HttpController/Admin/HttpTrackerTrait.php index 7efd41a..25ab397 100644 --- a/src/HttpController/Admin/HttpTrackerTrait.php +++ b/src/HttpController/Admin/HttpTrackerTrait.php @@ -122,7 +122,7 @@ public function index() try { $data = $Mysqli->query($builder)->getResult(); if (empty($data)) { - $data = parent::__after_index([], 0) + ['sql' => $sql]; + $data = parent::__after_index() + ['sql' => $sql]; $this->success($data); return; } diff --git a/src/HttpController/Admin/LogLoginTrait.php b/src/HttpController/Admin/LogLoginTrait.php index caabb63..fa665b9 100644 --- a/src/HttpController/Admin/LogLoginTrait.php +++ b/src/HttpController/Admin/LogLoginTrait.php @@ -14,12 +14,12 @@ protected function __search() return $this->_search($where); } - protected function __after_index($items, $total) + protected function __after_index($items = [], $total = 0, $summer = []) { foreach ($items as &$value) { $value->relation = $value->relation ?? []; } - return parent::__after_index($items, $total); + return parent::__after_index($items, $total, $summer); } } diff --git a/src/HttpController/Admin/LogSqlTrait.php b/src/HttpController/Admin/LogSqlTrait.php index fb30c54..28c7e1b 100644 --- a/src/HttpController/Admin/LogSqlTrait.php +++ b/src/HttpController/Admin/LogSqlTrait.php @@ -32,12 +32,12 @@ protected function __search() return null; } - protected function __after_index($items, $total) + protected function __after_index($items = [], $total = 0, $summer = []) { foreach ($items as &$value) { $value->relation = $value->relation ?? []; } - return parent::__after_index($items, $total); + return parent::__after_index($items, $total, $summer); } }