api接口

This commit is contained in:
wanyongkang
2020-10-05 13:43:53 +08:00
parent a331e3f1d5
commit ce067b91dc
9 changed files with 198 additions and 103 deletions

View 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);
}
}