v1.2.8 球员页增强:位置筛选标签(全部/控卫/分卫/小前/大前/中锋) + 分页控件(24条/页,页码省略号),可与搜索组合筛选

This commit is contained in:
2026-08-17 23:46:22 +08:00
parent bac19202b7
commit 14317a44a2
5 changed files with 90 additions and 8 deletions
+20
View File
@@ -157,6 +157,26 @@ def get_player(player_id):
return _fmt_player(p) if p else None
# ================================================================== 球员列表(前台分页版)
def list_players(q="", position="", page=1, size=24):
"""前台球员列表:关键词 + 位置筛选 + 分页(区别于 search_players 工具版)"""
q = expand_aliases((q or "").strip())
conds, args = [], []
if q:
like = f"%{fuzzy(q)}%"
conds.append("(p.name LIKE ? ESCAPE '\\' OR p.name_en LIKE ? ESCAPE '\\' OR t.name LIKE ? ESCAPE '\\')")
args += [like, like, like]
if position:
conds.append("p.position=?")
args.append(position)
where = ("WHERE " + " AND ".join(conds)) if conds else ""
total = query_one(f"SELECT COUNT(*) AS c FROM players p LEFT JOIN teams t ON p.team_id=t.id {where}", args)["c"]
rows = query(f"""SELECT p.*, t.name AS team_name FROM players p LEFT JOIN teams t ON p.team_id=t.id
{where} ORDER BY p.season_pts DESC LIMIT ? OFFSET ?""",
args + [size, (page - 1) * size])
return {"results": [_fmt_player(r) for r in rows], "total": total, "page": page, "size": size}
# ================================================================== 比赛
_TEAM_PAT = None