swoole-framwork/app/controller/UserController.php
2024-05-21 14:33:56 +08:00

51 lines
1.1 KiB
PHP

<?php
namespace App\controller;
use App\model\User;
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()
{
//$this->db->select('select sleep(1)');
//User::query('select sleep(3)');
$user = User::first();
return ['uid'=>33,'username'=>$user];
}
/**
* @RequestMapping(value="/user/{uid:\d+}")
*/
public function user(int $uid,Request $request, Response $response)
{
$user = $this->db->select('select * from eb_user where id = 1');
return ['uid'=>$uid,'username'=>$user];
}
/**
* @RequestMapping(value="/redirect")
*/
public function redirect(Request $request,Response $response)
{
$response->writeRedirect('http://www.baihand.com');
}
}