178 lines
4.5 KiB
PHP
178 lines
4.5 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\Login\LoginService;
|
|
use App\Service\Admin\User\RoleMenuService;
|
|
use App\Service\Admin\User\RoleService;
|
|
use Exception;
|
|
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();
|
|
}
|
|
|
|
/**
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
#[RequestMapping(path: "role_add", methods: "POST")]
|
|
#[Scene(scene: "role_add")]
|
|
public function role_add(AuthRequest $request)
|
|
{
|
|
return (new RoleService)->add();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
#[RequestMapping(path: "role_edit", methods: "POST")]
|
|
#[Scene(scene: "role_edit")]
|
|
public function roleEdit()
|
|
{
|
|
return (new RoleService)->edit();
|
|
}
|
|
|
|
/**
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws Exception
|
|
*/
|
|
#[RequestMapping(path: "role_change_status", methods: "POST")]
|
|
#[Scene(scene: "role_change_status")]
|
|
public function roleChangeStatus(AuthRequest $request)
|
|
{
|
|
return (new RoleService)->changeStatus();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "role_list", methods: "GET")]
|
|
#[Scene(scene: "role_list")]
|
|
public function roleList(AuthRequest $request)
|
|
{
|
|
return (new RoleService)->handle();
|
|
}
|
|
|
|
/**
|
|
* @param AuthRequest $request
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws \RedisException
|
|
*/
|
|
#[RequestMapping(path: "role", methods: "GET")]
|
|
#[Scene(scene: "role_info")]
|
|
public function role(AuthRequest $request): array
|
|
{
|
|
return (new RoleService)->details();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "logOut", methods: "GET")]
|
|
#[Scene(scene: "logOut")]
|
|
public function logOut()
|
|
{
|
|
return (new LoginService)->logOut();
|
|
}
|
|
}
|