diff --git a/database/models/base.py b/database/models/base.py index eef1e8d..1551e82 100644 --- a/database/models/base.py +++ b/database/models/base.py @@ -67,6 +67,24 @@ def generate_import_token(self): self.save() return self.import_token + @staticmethod + def by_qq(qq): + fail1 = False + fail2 = False + try: + player = Player.get(Player.bind_qq == qq) + return player + except Exception: + fail1 = True + try: + player = Player.get(Player.qq_channel_uid == qq) + return player + except Exception: + fail2 = True + if fail1 and fail2: + raise Exception("Player not found") + return None + class Developer(BaseModel): nickname = CharField() diff --git a/database/routes/chunithm.py b/database/routes/chunithm.py index f888353..15e603e 100644 --- a/database/routes/chunithm.py +++ b/database/routes/chunithm.py @@ -268,7 +268,7 @@ async def query_player_chuni(): obj = await request.json try: if "qq" in obj: - p: Player = Player.get(Player.bind_qq == obj["qq"]) + p: Player = Player.by_qq(obj["qq"]) else: username = obj["username"] p: Player = Player.get(Player.username == username) diff --git a/database/routes/maimai.py b/database/routes/maimai.py index 8203624..952788a 100644 --- a/database/routes/maimai.py +++ b/database/routes/maimai.py @@ -171,7 +171,7 @@ async def dev_get_records(): if qq == "": player: Player = Player.get(Player.username == username) else: - player: Player = Player.get(Player.bind_qq == qq) + player: Player = Player.by_qq(qq) except Exception: return {"message": "no such user"}, 400 r = NewRecord.raw('select newrecord.achievements, newrecord.fc, newrecord.fs, newrecord.dxScore, chart.ds as ds, chart.level as level, chart.difficulty as diff, music.type as `type`, music.id as `id`, music.is_new as is_new, music.title as title from newrecord, chart, music where player_id = %s and chart_id = chart.id and chart.music_id = music.id', player.id) @@ -242,7 +242,7 @@ async def query_player(): obj = await request.json try: if "qq" in obj: - p: Player = Player.get(Player.bind_qq == obj["qq"]) + p: Player = Player.by_qq(obj["qq"]) else: username = obj["username"] p: Player = Player.get(Player.username == username) diff --git a/web/src/components/Profile.vue b/web/src/components/Profile.vue index 772f81a..fde6811 100644 --- a/web/src/components/Profile.vue +++ b/web/src/components/Profile.vue @@ -221,7 +221,7 @@ export default { data: () => { return { valid: false, - login: true, + login: false, username: "", visible: false, delVisible: false,