代码语言:javascript复制
public function getAdminOpLogListByPager(AdminOpLogListContext $context, $sys)
{
$op = Db::table('admin_op_log')
->where('sys', $sys);
if ($context->admin_id_arr != [-1]) {
$op = $op->whereIn('admin_id', $context->admin_id_arr);
}
if ($context->field) {
if ($context->lifting == 1) {
$op = $op->order($context->field . ' desc');
} else {
$op = $op->order($context->field . ' asc');
}
}
//总共记录
$total = $op->count();
$list = $op->limit($context->page_count * ($context->page_no - 1), $context->page_count 1)->select();
$count = count($list);
$hasMore = false;
if ($count > (int)$context->page_count) {
$hasMore = true;
array_pop($list);
}
return [
'data' => array_values($list),
'total' => $total,
'has_more' => $hasMore
];
}
//处理前端样式
$data = $result['data'];
//总共记录
$total_count = $result['total'];
//总页数
$totalPage = ceil($totalCount / $context->page_count);
$page_info = [
'page_no' => (int)$context->page_no,
'page_count' => (int)$context->page_count,
'page_total' => $totalPage,
'total' => $totalCount,
];
return [
'page_info' => $page_info,
'list' => array_values($data)
];
//总页数
$totalPage = ceil($totalCount / $pageCount);
return [
'page_no' => (int)$pageNo,
'page_count' => (int)$pageCount,
'has_more' => $result['has_more'],
'list' => array_values($data),
'total' => $totalPage,
];
复制代码