尝试修复挑战系统中的用户名错误

This commit is contained in:
2025-11-13 00:23:33 +08:00
parent d0825f3f48
commit 7b84351b81
4 changed files with 86 additions and 13 deletions

View File

@@ -202,6 +202,18 @@ class WPSConfigAPI(WPSAPI):
value = record.get("username")
return str(value) if value else f"user_{user_id}"
def find_user_id_by_username(self, username: str) -> Optional[int]:
text = (username or "").strip()
if not text:
return None
cursor = get_db().conn.cursor()
cursor.execute(
"SELECT user_id FROM user_info WHERE username = ? COLLATE NOCASE",
(text,),
)
row = cursor.fetchone()
return int(row["user_id"]) if row else None
def get_user_url(self, user_id: int) -> Optional[str]:
record = self._get_user_record(user_id)
if not record: