fix: 将 app/ 下的所有代码中与sql相关的所有隐式类型转换替换为显式类型转换

This commit is contained in:
jimmy-sketch
2025-07-24 12:30:24 +08:00
parent 4a16a9598f
commit 6647e5cd04
5 changed files with 10 additions and 7 deletions

3
.gitignore vendored
View File

@@ -205,4 +205,5 @@ cython_debug/
marimo/_static/ marimo/_static/
marimo/_lsp/ marimo/_lsp/
__marimo__/ __marimo__/
bancho.py-master/* bancho.py-master/*
.vscode/settings.json

View File

@@ -84,7 +84,7 @@ def authenticate_user_legacy(db: Session, name: str, password: str) -> Optional[
return None return None
# 3. 验证密码 # 3. 验证密码
if not user.pw_bcrypt: if not (user.pw_bcrypt is None and user.pw_bcrypt != ""):
return None return None
# 4. 检查缓存 # 4. 检查缓存

View File

@@ -147,6 +147,7 @@ class User(Base):
lazer_replays_watched = relationship( lazer_replays_watched = relationship(
"LazerUserReplaysWatched", back_populates="user", cascade="all, delete-orphan" "LazerUserReplaysWatched", back_populates="user", cascade="all, delete-orphan"
) )
# ============================================ # ============================================

View File

@@ -60,7 +60,7 @@ async def oauth_token(
# 存储令牌 # 存储令牌
store_token( store_token(
db, db,
user.id, getattr(user, "id"),
access_token, access_token,
refresh_token_str, refresh_token_str,
settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60, settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,
@@ -92,9 +92,10 @@ async def oauth_token(
new_refresh_token = generate_refresh_token() new_refresh_token = generate_refresh_token()
# 更新令牌 # 更新令牌
user_id = int(getattr(token_record, 'user_id'))
store_token( store_token(
db, db,
token_record.user_id, user_id,
access_token, access_token,
new_refresh_token, new_refresh_token,
settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60, settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,

View File

@@ -58,9 +58,9 @@ def convert_db_user_to_api_user(
user_stats = create_default_lazer_statistics(ruleset) user_stats = create_default_lazer_statistics(ruleset)
# 获取国家信息 # 获取国家信息
country_code = db_user.country_code if db_user.country_code else "XX" country_code = db_user.country_code if db_user.country_code is not None else "XX"
country = Country(code=country_code, name=get_country_name(country_code)) country = Country(code=str(country_code), name=get_country_name(str(country_code)))
# 获取 Kudosu 信息 # 获取 Kudosu 信息
kudosu = Kudosu(available=0, total=0) kudosu = Kudosu(available=0, total=0)
@@ -346,7 +346,7 @@ def convert_db_user_to_api_user(
id=user_id, id=user_id,
username=user_name, username=user_name,
avatar_url=avatar_url, avatar_url=avatar_url,
country_code=country_code, country_code=str(country_code),
default_group=profile.default_group if profile else "default", default_group=profile.default_group if profile else "default",
is_active=profile.is_active if profile else True, is_active=profile.is_active if profile else True,
is_bot=profile.is_bot if profile else False, is_bot=profile.is_bot if profile else False,