26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
from typing import List
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from backend.api.deps import AuthUser, get_current_user
|
|
from backend.modules.users.models import RoleName
|
|
|
|
router = APIRouter(prefix="/api/v1/menus", tags=["menus"])
|
|
|
|
|
|
@router.get("", response_model=List[dict])
|
|
async def get_menus(auth_user: AuthUser = Depends(get_current_user)) -> List[dict]:
|
|
menus = [
|
|
{"label": "EC2 实例", "key": "instances", "path": "/instances"},
|
|
{"label": "AWS 凭证", "key": "credentials", "path": "/credentials"},
|
|
{"label": "任务中心", "key": "jobs", "path": "/jobs"},
|
|
{"label": "审计日志", "key": "audit", "path": "/audit"},
|
|
]
|
|
if auth_user.role_name == RoleName.ADMIN.value:
|
|
menus.insert(0, {"label": "仪表盘", "key": "dashboard", "path": "/"})
|
|
menus.append({"label": "客户管理", "key": "customers", "path": "/customers"})
|
|
menus.append({"label": "用户管理", "key": "users", "path": "/users"})
|
|
elif auth_user.role_name == RoleName.CUSTOMER_ADMIN.value:
|
|
menus.append({"label": "用户管理", "key": "users", "path": "/users"})
|
|
return menus
|