feat: add tenant_domain CRUD API dspy files and updated index.ui
This commit is contained in:
parent
7940d50aed
commit
3be62ba01c
10
wwwroot/api/tenant_domain_create.dspy
Normal file
10
wwwroot/api/tenant_domain_create.dspy
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == "NaN" or v == "null":
|
||||||
|
ns[k] = None
|
||||||
|
if not ns.get("id"):
|
||||||
|
ns["id"] = getID()
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext("pipeline") as sor:
|
||||||
|
await sor.C("tenant_domain", ns)
|
||||||
|
return {"status": "ok"}
|
||||||
9
wwwroot/api/tenant_domain_delete.dspy
Normal file
9
wwwroot/api/tenant_domain_delete.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ns = params_kw.copy()
|
||||||
|
rid = ns.get("id")
|
||||||
|
if not rid:
|
||||||
|
return {"status": "error", "message": "id required"}
|
||||||
|
ns["rid"] = rid
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext("pipeline") as sor:
|
||||||
|
await sor.sqlExe("DELETE FROM tenant_domain WHERE id=${rid}$", ns)
|
||||||
|
return {"status": "ok"}
|
||||||
15
wwwroot/api/tenant_domain_get.dspy
Normal file
15
wwwroot/api/tenant_domain_get.dspy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == "NaN" or v == "null":
|
||||||
|
ns[k] = None
|
||||||
|
page = int(ns.get("page", 1))
|
||||||
|
pagerows = int(ns.get("rows", 20))
|
||||||
|
offset = (page - 1) * pagerows
|
||||||
|
ns["pagerows"] = pagerows
|
||||||
|
ns["offset"] = offset
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext("pipeline") as sor:
|
||||||
|
recs = await sor.sqlExe("SELECT count(*) as total FROM tenant_domain", {})
|
||||||
|
total = recs[0].total if recs else 0
|
||||||
|
recs = await sor.sqlExe("SELECT * FROM tenant_domain ORDER BY created_at desc LIMIT ${pagerows}$ OFFSET ${offset}$", ns)
|
||||||
|
return {"total": total, "rows": [dict(r) for r in recs]}
|
||||||
12
wwwroot/api/tenant_domain_update.dspy
Normal file
12
wwwroot/api/tenant_domain_update.dspy
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == "NaN" or v == "null":
|
||||||
|
ns[k] = None
|
||||||
|
rid = ns.get("id")
|
||||||
|
if not rid:
|
||||||
|
return {"status": "error", "message": "id required"}
|
||||||
|
ns["rid"] = rid
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext("pipeline") as sor:
|
||||||
|
await sor.sqlExe("UPDATE tenant_domain SET domain=${domain}$, resellerid=${resellerid}$, orgid=${orgid}$, status=${status}$ WHERE id=${rid}$", ns)
|
||||||
|
return {"status": "ok"}
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"height": "100%",
|
"height": "100%",
|
||||||
"css": "card",
|
"css": "card",
|
||||||
"title": "域名列表",
|
"title": "域名列表",
|
||||||
"data_url": "{{entire_url('/tenant/tenant_domain')}}",
|
"data_url": "{{entire_url('/tenant/api/tenant_domain_get.dspy')}}",
|
||||||
"data_method": "GET",
|
"data_method": "GET",
|
||||||
"page_rows": 20,
|
"page_rows": 20,
|
||||||
"toolbar": {
|
"toolbar": {
|
||||||
@ -85,7 +85,7 @@
|
|||||||
"dismiss_events": ["cancel", "submited"]
|
"dismiss_events": ["cancel", "submited"]
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"url": "{{entire_url('/tenant/tenant_domain')}}"
|
"url": "{{entire_url('/tenant/api/tenant_domain_get.dspy')}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@
|
|||||||
"dismiss_events": ["cancel", "submited"]
|
"dismiss_events": ["cancel", "submited"]
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"url": "{{entire_url('/tenant/tenant_domain')}}"
|
"url": "{{entire_url('/tenant/api/tenant_domain_get.dspy')}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -108,7 +108,7 @@
|
|||||||
"target": "self",
|
"target": "self",
|
||||||
"method": "delete_rows",
|
"method": "delete_rows",
|
||||||
"options": {
|
"options": {
|
||||||
"url": "{{entire_url('/tenant/tenant_domain')}}"
|
"url": "{{entire_url('/tenant/api/tenant_domain_get.dspy')}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user