Skip to content

Commit

Permalink
[feature] back-end support
Browse files Browse the repository at this point in the history
  • Loading branch information
Diving-Fish committed Sep 20, 2023
1 parent 3303b72 commit 1c29b7b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions database/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion database/routes/chunithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions database/routes/maimai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default {
data: () => {
return {
valid: false,
login: true,
login: false,
username: "",
visible: false,
delVisible: false,
Expand Down

0 comments on commit 1c29b7b

Please sign in to comment.