2024-05-20 11:51:07 +08:00
|
|
|
<?php
|
|
|
|
namespace App\controller;
|
2024-05-21 14:33:56 +08:00
|
|
|
use App\model\User;
|
2024-05-20 11:51:07 +08:00
|
|
|
use Core\annotations\Bean;
|
|
|
|
use Core\annotations\Value;
|
|
|
|
use Core\annotations\DB;
|
|
|
|
use Core\annotations\RequestMapping;
|
|
|
|
use Core\http\Request;
|
|
|
|
use Core\http\Response;
|
|
|
|
use Core\init\MyDB;
|
|
|
|
/**
|
|
|
|
* @Bean()
|
|
|
|
*/
|
|
|
|
class UserController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @DB()
|
|
|
|
* @var MyDB
|
|
|
|
*/
|
|
|
|
private $db;
|
|
|
|
/**
|
|
|
|
* @Value ()
|
|
|
|
*/
|
|
|
|
public $version = '1.0';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @RequestMapping(value="/user/test")
|
|
|
|
*/
|
|
|
|
public function test()
|
|
|
|
{
|
2024-05-21 14:33:56 +08:00
|
|
|
//$this->db->select('select sleep(1)');
|
|
|
|
//User::query('select sleep(3)');
|
|
|
|
$user = User::first();
|
|
|
|
return ['uid'=>33,'username'=>$user];
|
2024-05-20 11:51:07 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @RequestMapping(value="/user/{uid:\d+}")
|
|
|
|
*/
|
|
|
|
public function user(int $uid,Request $request, Response $response)
|
|
|
|
{
|
2024-05-21 14:33:56 +08:00
|
|
|
$user = $this->db->select('select * from eb_user where id = 1');
|
|
|
|
return ['uid'=>$uid,'username'=>$user];
|
2024-05-20 11:51:07 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @RequestMapping(value="/redirect")
|
|
|
|
*/
|
|
|
|
public function redirect(Request $request,Response $response)
|
|
|
|
{
|
|
|
|
$response->writeRedirect('http://www.baihand.com');
|
|
|
|
}
|
|
|
|
}
|