51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
namespace App\controller;
|
|
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()
|
|
{
|
|
return $this->db->table("user")->get();
|
|
//return "route doc";
|
|
}
|
|
/**
|
|
* @RequestMapping(value="/user/{uid:\d+}")
|
|
*/
|
|
public function user(int $uid,Request $request, Response $response)
|
|
{
|
|
//var_dump($r->getQueryParams());
|
|
//$response->testWrite('abc');
|
|
//return "bbb---".$uid;
|
|
return ['uid'=>$uid,'username'=>'ttt'];
|
|
}
|
|
/**
|
|
* @RequestMapping(value="/redirect")
|
|
*/
|
|
public function redirect(Request $request,Response $response)
|
|
{
|
|
$response->writeRedirect('http://www.baihand.com');
|
|
}
|
|
} |