feat: 选表时可以查看这张表的字段

This commit is contained in:
2026-11-10 09:21:43 +08:00
parent 2346d80f8e
commit 4a29a1ec1b
3 changed files with 106 additions and 3 deletions
+12
View File
@@ -259,6 +259,18 @@ def _csv(columns: list[dict], rows: list[dict]) -> bytes:
return buffer.getvalue().encode("utf-8-sig")
async def table_fields(client: NqiClient, tablename: str) -> list[dict]:
await ensure_session(client)
rows = await _columns(client, tablename)
fields = []
for row in rows:
name = str(row.get("columnname_cn") or row.get("columnname") or "").strip()
if not name:
continue
fields.append({"name": name, "type": str(row.get("datatype") or "").strip()})
return fields
async def _columns(client: NqiClient, tablename: str) -> list[dict]:
payload = await _post_json(client, f"{PAGE}/getSelectTable", {"tablename": tablename})
rows = payload.get("CFG_ADHOC_CONF_TABLE") if isinstance(payload, dict) else None