980a2db6d9
- 基础设施层 async:SQLAlchemy 异步引擎/会话、33 Repository async 化、models/security/seed 迁入 infrastructure、新增 cache.py(redis.asyncio) 与 oss.py(aioboto3) - 接口层:routers 迁 api/routers 并全 async,dependencies 迁 api/dependencies(get_db/get_current_user async) - 依赖:sqlalchemy[asyncio]/aiosqlite/asyncmy/redis/aioboto3;config 异步 URL + Redis/OSS 配置 - 删除废弃:旧同步 db/dependencies/repositories/storage - 验证:平台 19 路由 + 培训 48 路由全注册;/health /auth/login /auth/me /admin/tasks /notifications 等接口 async 可用
47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""开放平台端点:开发者工作台 / 应用 / 插件 / 技能 / API 凭证。"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from ..dependencies import get_db
|
|
from ...rbac import require_roles
|
|
from ...infrastructure.repositories import Database
|
|
|
|
router = APIRouter(prefix="/developer", tags=["developer"])
|
|
|
|
|
|
async def _page(port: str, page: str):
|
|
async def handler(db: Database = Depends(get_db)):
|
|
return await db.portal_pages.get(port, page) or {"items": []}
|
|
|
|
return handler
|
|
|
|
|
|
@router.get("/dashboard", summary="开发者工作台")
|
|
async def dev_dashboard(db: Database = Depends(get_db), _u: dict = Depends(require_roles("developer"))):
|
|
return await db.portal_pages.get("developer", "dashboard") or {"stats": []}
|
|
|
|
|
|
@router.get("/apps", summary="我的应用")
|
|
async def dev_apps(db: Database = Depends(get_db), _u: dict = Depends(require_roles("developer"))):
|
|
return await db.portal_pages.get("developer", "apps") or {"items": []}
|
|
|
|
|
|
@router.get("/plugins", summary="我的插件")
|
|
async def dev_plugins(db: Database = Depends(get_db), _u: dict = Depends(require_roles("developer"))):
|
|
return await db.portal_pages.get("developer", "plugins") or {"items": []}
|
|
|
|
|
|
@router.get("/skills", summary="技能市场")
|
|
async def dev_skills(db: Database = Depends(get_db), _u: dict = Depends(require_roles("developer"))):
|
|
return await db.portal_pages.get("developer", "skills") or {"items": []}
|
|
|
|
|
|
@router.get("/api-keys", summary="API 凭证")
|
|
async def dev_api_keys(db: Database = Depends(get_db), _u: dict = Depends(require_roles("developer"))):
|
|
return {"items": [
|
|
{"id": "key_001", "name": "生产环境", "prefix": "pa_live_****abcd", "created_at": "2026-07-01"},
|
|
{"id": "key_002", "name": "测试环境", "prefix": "pa_test_****wxyz", "created_at": "2026-07-05"},
|
|
], "note": "演示:凭证仅展示脱敏前缀"}
|