添加用户消息记录接口;

This commit is contained in:
karlcarlo
2025-12-11 03:53:47 +08:00
parent 6029da058a
commit 420fed4bcf
49 changed files with 7574 additions and 426 deletions

View File

@@ -0,0 +1,68 @@
from fastapi import Depends, HTTPException
from typing import Dict
from app.services.auth_service import get_access_token, get_token_info, get_jsapi_ticket, get_ticket_info
async def get_valid_token() -> str:
"""
依赖函数:获取有效的access_token
如果获取失败,抛出HTTP异常
"""
try:
token = get_access_token()
return token
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"获取access_token失败: {str(e)}"
)
async def get_token_information() -> Dict:
"""
依赖函数:获取token的详细信息
"""
try:
token_info = get_token_info()
return token_info
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"获取token信息失败: {str(e)}"
)
async def get_valid_ticket() -> str:
"""
依赖函数:获取有效的jsapi_ticket
如果获取失败,抛出HTTP异常
"""
try:
ticket = get_jsapi_ticket()
return ticket
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"获取jsapi_ticket失败: {str(e)}"
)
async def get_ticket_information() -> Dict:
"""
依赖函数:获取ticket的详细信息
"""
try:
ticket_info = get_ticket_info()
return ticket_info
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"获取ticket信息失败: {str(e)}"
)
# 创建依赖实例
token_dependency = Depends(get_valid_token)
token_info_dependency = Depends(get_token_information)
ticket_dependency = Depends(get_valid_ticket)
ticket_info_dependency = Depends(get_ticket_information)