132 lines
3.3 KiB
PHP
132 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Admin;
|
|
|
|
use App\Controller\AbstractController;
|
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
|
use App\Request\Admin\AuthRequest;
|
|
use App\Service\Admin\User\RoleMenuService;
|
|
use App\Service\Admin\User\RoleService;
|
|
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;
|
|
|
|
#[Controller(prefix: "admin/auth")]
|
|
#[Middlewares([
|
|
JwtAuthMiddleware::class,
|
|
])]
|
|
class AuthController extends AbstractController
|
|
{
|
|
/**
|
|
* 添加菜单
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
#[RequestMapping(path: "menu_add", methods: "POST")]
|
|
#[Scene(scene: "menu_add")]
|
|
public function menuAdd(AuthRequest $request)
|
|
{
|
|
return (new RoleMenuService)->add();
|
|
}
|
|
|
|
/**
|
|
* 修改菜单
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
#[RequestMapping(path: "menu_edit", methods: "POST")]
|
|
#[Scene(scene: "menu_edit")]
|
|
public function menuEdit(AuthRequest $request)
|
|
{
|
|
return (new RoleMenuService)->edit();
|
|
}
|
|
|
|
/**
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws \RedisException
|
|
*/
|
|
#[RequestMapping(path: "menu_del", methods: "GET")]
|
|
#[Scene(scene: "menu_del")]
|
|
public function menuDel(AuthRequest $request)
|
|
{
|
|
return (new RoleMenuService)->del();
|
|
}
|
|
|
|
/**
|
|
* 菜单列表
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws \RedisException
|
|
*/
|
|
#[RequestMapping(path: "menu_list", methods: "GET")]
|
|
public function menuList()
|
|
{
|
|
return (new RoleMenuService)->handle();
|
|
}
|
|
|
|
/**
|
|
* 菜单详情
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "menu", methods: "GET")]
|
|
#[Scene(scene: "menu_info")]
|
|
public function menu(AuthRequest $request)
|
|
{
|
|
return (new RoleMenuService)->details();
|
|
}
|
|
|
|
/**
|
|
* 构建菜单缓存
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws \RedisException
|
|
*/
|
|
#[RequestMapping(path: "menu_build_cache", methods: "GET")]
|
|
public function buildMenuCache()
|
|
{
|
|
return (new RoleMenuService)->buildCache();
|
|
}
|
|
|
|
public function role_add(AuthRequest $request)
|
|
{
|
|
return (new RoleService)->add();
|
|
}
|
|
|
|
public function role_edit()
|
|
{
|
|
return (new RoleService)->edit();
|
|
}
|
|
|
|
public function role_status()
|
|
{
|
|
return (new RoleService)->changeStatus();
|
|
}
|
|
|
|
public function role_list()
|
|
{
|
|
return (new RoleService)->handle();
|
|
}
|
|
|
|
#[RequestMapping(path: "role", methods: "GET")]
|
|
#[Scene(scene: "role_info")]
|
|
public function role(AuthRequest $request)
|
|
{
|
|
return (new RoleService)->details();
|
|
}
|
|
}
|