82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Admin;
|
|
|
|
use App\Controller\AbstractController;
|
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
|
use App\Request\Admin\CityRequest;
|
|
use App\Service\Admin\System\CityService;
|
|
use Hyperf\HttpServer\Annotation\Controller;
|
|
use Hyperf\HttpServer\Annotation\Middlewares;
|
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
|
use Hyperf\Validation\Annotation\Scene;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use RedisException;
|
|
|
|
#[Controller(prefix: "admin/city")]
|
|
#[Middlewares([
|
|
JwtAuthMiddleware::class,
|
|
])]
|
|
class CityController extends AbstractController
|
|
{
|
|
/**
|
|
* @param CityRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "add", methods: "POST")]
|
|
#[Scene(scene: "add")]
|
|
public function add(CityRequest $request): array
|
|
{
|
|
return (new CityService)->add();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws RedisException
|
|
*/
|
|
#[RequestMapping(path: "list", methods: "GET")]
|
|
#[Scene(scene: "list")]
|
|
public function list(): array
|
|
{
|
|
return (new CityService)->handle();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "edit", methods: "GET")]
|
|
#[Scene(scene: "edit")]
|
|
public function edit(): array
|
|
{
|
|
return (new CityService)->changeStatus();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "del", methods: "GET")]
|
|
#[Scene(scene: "del")]
|
|
public function delete(): array
|
|
{
|
|
return (new CityService)->delete();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws RedisException
|
|
*/
|
|
#[RequestMapping(path: "info", methods: "GET")]
|
|
#[Scene(scene: "info")]
|
|
public function info(): array
|
|
{
|
|
return (new CityService)->info();
|
|
}
|
|
}
|