整合 dsAiTeachingModel 接口

This commit is contained in:
chengminglong
2025-08-18 10:20:16 +08:00
parent 7b149f0f51
commit b2d5069d79
39 changed files with 1705 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
# dependencies.py
from fastapi import Request, HTTPException, status, Header
from Util.JwtUtil import *
async def get_current_user(token: str = Header(None, description="Authorization token")):
if token is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="未提供令牌,请登录后使用!",
headers={"WWW-Authenticate": "Bearer"},
)
token = token.split(" ")[1] if token.startswith("Bearer ") else token
payload = verify_token(token)
if payload is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="无法验证凭据,请登录后使用!",
headers={"WWW-Authenticate": "Bearer"},
)
user_id = payload.get("user_id")
identity_id = payload.get("identity_id")
if user_id is None or identity_id is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="无法验证用户,请重新登录后使用!",
headers={"WWW-Authenticate": "Bearer"},
)
return user_id