Skip to content

Commit 27af599

Browse files
committed
通用分页获取参数
通用分页获取参数
1 parent 2a2f609 commit 27af599

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

application/api/common/Page.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace app\api\common;
3+
4+
use think\Controller;
5+
6+
class Page extends Controller
7+
{
8+
/**
9+
* 设置分页数据
10+
* 如果客户端没传,默认取第一页,每页10条
11+
* 客户端传参数,以为客户端为准
12+
* @param array $data
13+
* @param int $page
14+
* @param int $size
15+
* @return array
16+
*/
17+
static function getPage($data = [],$page = 1,$size = 10){
18+
if(isset($data['page']) && isset($data['size'])){
19+
$where_page = $data['page'];
20+
$where_size = $data['size'];
21+
}else{
22+
$where_page = $page;
23+
$where_size = $size;
24+
}
25+
return [$where_page,$where_size];
26+
}
27+
}

0 commit comments

Comments
 (0)