feat: 选表时可以查看这张表的字段
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user