This commit is contained in:
knowpia
2022-10-10 09:14:16 +08:00
parent f43cd34e11
commit 529258318a

View File

@@ -14,9 +14,18 @@ class Share
$where = "id < ".$lastIndex; $where = "id < ".$lastIndex;
} }
$result['lastIndex'] = 0; $result['lastIndex'] = 0;
$list = Db::name("app_users")->where($where)->order("share_count desc,id desc")->limit(env("PAGE_COUNT"))->select()->toArray();
$list = Db::name("app_users")->where($where)->order('share_count desc,id desc')->limit(env("PAGE_COUNT"))->paginate([
"list_rows" => env("PAGE_COUNT"),
"page" => $lastIndex
]);
if (empty($list)) {
return show("获取成功", SUCCESS_CODE, $result);
}
foreach($list as $vo){ foreach($list as $vo){
$result['lastIndex'] = $vo['id'];
$result['data'][] = [ $result['data'][] = [
"id"=>$vo['id'], "id"=>$vo['id'],
"nickname"=>$vo['nickname'], "nickname"=>$vo['nickname'],
@@ -26,6 +35,12 @@ class Share
]; ];
} }
if ($list->currentPage() < $list->lastPage()) {
$result['lastIndex'] = $lastIndex + 1;
} else {
$result['lastIndex'] = 0;
}
if (count($list) < env("PAGE_COUNT")) { if (count($list) < env("PAGE_COUNT")) {
$result["lastIndex"] = 0; $result["lastIndex"] = 0;
} }