tenant/wwwroot/api/tenant_domain_get.dspy

31 lines
1.1 KiB
Plaintext

ns = params_kw.copy()
for k,v in ns.items():
if v == "NaN" or v == "null":
ns[k] = None
if "page" not in ns:
ns["page"] = 1
ns["sort"] = "created_at"
ns["order"] = "desc"
env = request._run_ns
async with get_sor_context(env, "tenant") as sor:
sql = """SELECT a.*, b.orgname as sub_distributor_id_text
FROM tenant_domain a
LEFT JOIN sage.organization b ON a.resellerid = b.id
ORDER BY a.created_at DESC"""
recs = await sor.sqlPaging(sql, ns)
rows = []
for r in recs["rows"]:
status_text = '启用' if r.status == 'active' else ('停用' if r.status == 'inactive' else r.status)
rows.append({
"id": r.id,
"domain": r.domain,
"resellerid": r.resellerid,
"sub_distributor_id": r.resellerid,
"sub_distributor_id_text": r.sub_distributor_id_text or r.resellerid,
"orgid": r.orgid,
"status": status_text,
"created_at": str(r.created_at),
"updated_at": str(r.updated_at)
})
return {"total": recs["total"], "rows": rows}