Skip to content

Commit

Permalink
feat: 更新__after_index
Browse files Browse the repository at this point in the history
  • Loading branch information
linkunyuan committed Oct 12, 2023
1 parent 56d7da7 commit c246e06
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/HttpController/Admin/AdminTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/HttpController/Admin/AuthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] : []);
}
Expand Down Expand Up @@ -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为索引数组,为空字段需要占位

Expand Down
2 changes: 1 addition & 1 deletion src/HttpController/Admin/HttpTrackerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/HttpController/Admin/LogLoginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/HttpController/Admin/LogSqlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit c246e06

Please sign in to comment.