..
This commit is contained in:
@@ -27,7 +27,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 校区列表.
|
||||
*/
|
||||
#[GetMapping(path: '/campus/list')]
|
||||
#[GetMapping(path: 'campus/list')]
|
||||
public function list(RequestInterface $request): array
|
||||
{
|
||||
$data = $request->all();
|
||||
@@ -77,7 +77,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 获取省份列表.
|
||||
*/
|
||||
#[GetMapping(path: '/campus/provinces')]
|
||||
#[GetMapping(path: 'campus/provinces')]
|
||||
public function provinces(): array
|
||||
{
|
||||
$provinces = Campus::level(1)
|
||||
@@ -92,7 +92,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 获取城市列表.
|
||||
*/
|
||||
#[GetMapping(path: '/campus/cities')]
|
||||
#[GetMapping(path: 'campus/cities')]
|
||||
public function cities(RequestInterface $request): array
|
||||
{
|
||||
$province = $request->input('province');
|
||||
@@ -113,7 +113,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 创建校区.
|
||||
*/
|
||||
#[PostMapping(path: '/campus')]
|
||||
#[PostMapping(path: 'campus')]
|
||||
public function create(RequestInterface $request): array
|
||||
{
|
||||
$data = $request->all();
|
||||
@@ -132,7 +132,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 获取校区详情.
|
||||
*/
|
||||
#[GetMapping(path: '/campus/{id}')]
|
||||
#[GetMapping(path: 'campus/{id}')]
|
||||
public function get(int $id): array
|
||||
{
|
||||
$campus = Campus::find($id);
|
||||
@@ -146,7 +146,7 @@ class CampusController extends AetherController
|
||||
/**
|
||||
* 更新校区.
|
||||
*/
|
||||
#[PutMapping(path: '/campus/{id}')]
|
||||
#[PutMapping(path: 'campus/{id}')]
|
||||
public function update(int $id, RequestInterface $request): array
|
||||
{
|
||||
$data = $request->all();
|
||||
@@ -172,7 +172,7 @@ class CampusController extends AetherController
|
||||
* 删除校区.
|
||||
* @throws Exception
|
||||
*/
|
||||
#[DeleteMapping(path: '/campus/{id}')]
|
||||
#[DeleteMapping(path: 'campus/{id}')]
|
||||
public function delete(int $id): array
|
||||
{
|
||||
$campus = Campus::find($id);
|
||||
38
app/Exception/Handler/AppExceptionHandler.php
Normal file
38
app/Exception/Handler/AppExceptionHandler.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace App\Exception\Handler;
|
||||
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\ExceptionHandler\ExceptionHandler;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Throwable;
|
||||
|
||||
class AppExceptionHandler extends ExceptionHandler
|
||||
{
|
||||
public function __construct(protected StdoutLoggerInterface $logger)
|
||||
{
|
||||
}
|
||||
|
||||
public function handle(Throwable $throwable, ResponseInterface $response)
|
||||
{
|
||||
$this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile()));
|
||||
$this->logger->error($throwable->getTraceAsString());
|
||||
return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.'));
|
||||
}
|
||||
|
||||
public function isValid(Throwable $throwable): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user