api接口
This commit is contained in:
38
app/api/controller/Index.php
Normal file
38
app/api/controller/Index.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\Test;
|
||||
use app\api\model\User;
|
||||
|
||||
class Index
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$test = new Test();
|
||||
$list = $test->field('user,operation,record,create_time')->order('id')->limit('50')->fetchAll();
|
||||
$count = $test->field('count(1) as count')->fetch();
|
||||
$data = [
|
||||
'Code'=>10000,
|
||||
'count'=>$count['count'],
|
||||
'data'=>$list
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//获取指定页码数据
|
||||
public function pageList()
|
||||
{
|
||||
if(!$_GET){
|
||||
die;
|
||||
}
|
||||
$page = ($_GET['page'] - 1) * 50;
|
||||
$test = new Test();
|
||||
$list = $test->limit("$page,50")->fetchAll();
|
||||
$data = [
|
||||
'Code'=>10000,
|
||||
'data'=>$list
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user