feat: 管理界面新增数据浏览页(服务端分页)

- 新增「数据」页:按制式筛选、CGI/小区名称搜索、四种排序,每页 20/50/100 条,数据库端 LIMIT/OFFSET 分页,越界页自动回退到最后一页
- 点击行查看详情:基础字段与 1 公里内高干扰小区数的本期/上期分制式对比
- 首次打开该页才加载,新批次入库后自动刷新;加载中状态与过期请求丢弃,避免界面卡顿
- 新增 GET /api/data 接口(仅管理员),读取失败返回 502
- MySQL 直连与 Metrix 接口两种模式都支持只读查询,接口模式浏览查询超时 20 秒;两种模式数值格式统一
- 搜索词转义引号与 LIKE 通配符,制式、排序、页大小走白名单
- 补充单元测试与中英文文案
This commit is contained in:
2026-11-06 18:02:36 +08:00
parent b487a54b94
commit 4fb44ab27a
10 changed files with 603 additions and 7 deletions
+10
View File
@@ -266,6 +266,16 @@ class MySqlSummaryStore:
for record in records
]
def select(self, sql: str, limit: int) -> list[dict[str, object]]:
try:
with self._connection() as connection, connection.cursor() as cursor:
cursor.execute(sql)
names = [column[0] for column in cursor.description or ()]
records = cursor.fetchmany(max(1, limit))
except pymysql.MySQLError as exc:
raise main.ProcessingError(f"MySQL query failed: {exc}") from exc
return [dict(zip(names, record, strict=True)) for record in records]
def ping(self) -> str:
connection = self._open(database=None)
try: