Files
hyperf_test/app/Controller/Test/ProxyController.php
2025-09-07 14:18:01 +08:00

73 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Controller\Test;
use App\Service\Test\Proxy\AopService;
use App\Service\Test\Proxy\BasicSubjectService;
use App\Service\Test\Proxy\DynamicProxyService;
use App\Service\Test\Proxy\Payment\PaymentService;
use App\Service\Test\Proxy\RemoteService;
use App\Service\Test\Proxy\UserInfoService;
use App\Service\Test\Proxy\UserService;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
#[Controller(prefix: 'proxy/test')]
class ProxyController
{
/**
* 静态代理
* @return array
*/
#[RequestMapping(path: 'basic', methods: 'GET')]
public function basic(): array
{
return (new BasicSubjectService)->handle();
}
/**
* 动态代理
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'dynamic', methods: 'GET')]
public function dynamic(): array
{
return (new DynamicProxyService)->handle();
}
/**
* aop代理
* @return array
*/
#[RequestMapping(path: 'payment', methods: 'GET')]
public function payment(): array
{
return (new AopService)->handle();
}
/**
* 缓存代理
* @return array
*/
#[RequestMapping(path: 'get_user_info', methods: 'GET')]
public function getUserInfo(): array
{
return (new UserService)->handle();
}
/**
* @return array
*/
#[RequestMapping(path: 'remote', methods: 'GET')]
public function remote(): array
{
return (new RemoteService)->handle();
}
}