基础数据-校区服务
This commit is contained in:
45
extend/Aether/PHP/Hyperf/AetherController.php
Normal file
45
extend/Aether/PHP/Hyperf/AetherController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Aether;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Hyperf\HttpServer\Contract\ResponseInterface;
|
||||
|
||||
abstract class AetherController
|
||||
{
|
||||
#[Inject]
|
||||
protected RequestInterface $request;
|
||||
|
||||
#[Inject]
|
||||
protected ResponseInterface $response;
|
||||
|
||||
/**
|
||||
* 获取请求参数.
|
||||
* @param string $key
|
||||
* @param mixed|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function requestParam(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return $this->request->input($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有请求参数.
|
||||
*/
|
||||
public function requestParams(): array
|
||||
{
|
||||
return $this->request->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回JSON响应.
|
||||
*/
|
||||
public function json(array $data): \Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user