46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
|
|
/**
|
|
* 首页接口
|
|
*/
|
|
class Index extends Api
|
|
{
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedRight = ['*'];
|
|
|
|
/**
|
|
* 首页
|
|
*
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->success('请求成功');
|
|
}
|
|
|
|
function GetRandStr($length){
|
|
//字符组合
|
|
$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
$len = strlen($str)-1;
|
|
$randstr = '';
|
|
for ($i=0;$i<$length;$i++) {
|
|
$num=mt_rand(0,$len);
|
|
$randstr .= $str[$num];
|
|
}
|
|
return $randstr;
|
|
}
|
|
|
|
public function addStu()
|
|
{
|
|
$li = db('student')->find();
|
|
$array = array('identifier'=>rand(10000,99999),'nickname'=>$this->GetRandStr(8),'mobile'=>rand(10000000000,99999999999),'password'=>$this->GetRandStr(8),'avatar'=>'/uploads/20220908/b7c04fd15608f8b905d9808a401c9c02.jpg','gender'=>1,'birthday'=>'2022-08-08','age'=>10,'type'=>1,'disabled'=>0,'city'=>'哈尔滨','school'=>'xxx小学');
|
|
for ($i=1; $i<=50; $i++)
|
|
{
|
|
db('student')->insert($array);
|
|
}
|
|
}
|
|
}
|