dev
This commit is contained in:
@@ -2,10 +2,8 @@ import base64
|
||||
import hmac
|
||||
import json
|
||||
import time
|
||||
from typing import Optional
|
||||
from core.character.adventure import get_adv_info
|
||||
from core.basic.character import Character
|
||||
from fastapi import Header, Request
|
||||
from fastapi import Header
|
||||
from api.core.exception import ResponseException
|
||||
|
||||
|
||||
@@ -67,7 +65,7 @@ def deleteToken(token, redis, env):
|
||||
return token
|
||||
|
||||
|
||||
def uid(access_uid: Optional[str] = Header(None)):
|
||||
def uid(access_uid: str | None = Header(None)):
|
||||
try:
|
||||
return int(access_uid)
|
||||
except Exception:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import gzip
|
||||
from fastapi import Request, APIRouter, FastAPI
|
||||
from fastapi.responses import Response
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
from fastapi.middleware.gzip import GZipMiddleware
|
||||
from fastapi.routing import APIRoute
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ def get_redis_info(redis, key, fun,without_gzip=False):
|
||||
info = json.loads(redis.get(key))
|
||||
else:
|
||||
info = json.loads(gzip_unzip(redis.get(key)))
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
info = None
|
||||
if info is None:
|
||||
info = fun()
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import base64
|
||||
import json
|
||||
from typing import Generic, TypeVar
|
||||
from pydantic import Field
|
||||
from pydantic.generics import GenericModel
|
||||
import gzip # 导入 gzip 模块
|
||||
from io import BytesIO # 从 io 模块导入 BytesIO 类
|
||||
|
||||
|
||||
T = TypeVar('T')
|
||||
|
||||
|
||||
class Return(GenericModel, Generic[T]):
|
||||
code: int = 200
|
||||
message: str = ''
|
||||
data: T | dict | str = None
|
||||
|
||||
|
||||
code: int = Field(..., description='响应状态码')
|
||||
"""响应状态码"""
|
||||
message: str = Field(..., description='响应消息')
|
||||
"""响应消息"""
|
||||
data: T = Field(..., description='响应数据')
|
||||
"""响应数据"""
|
||||
|
||||
# 定义一个函数,将字符串压缩为 gzip 格式,并进行 base64 编码后返回结果
|
||||
def gzip_str(to_gzip: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user