dapi/wwwroot/get_apikey.dspy
2026-05-20 21:12:52 +08:00

49 lines
835 B
Plaintext

debug(f'{params_kw=}')
env = request._run_ns
userid = await get_user()
orgid = await get_userorgid()
if userid is None:
return {
"status": "error",
"data": {
"message": "need login"
}
}
try:
async with get_sor_context(env, 'dapi') as sor:
ns = {
"id": params_kw.id,
"orgid":orgid,
"userid":userid
}
sql = """select a.*,
b.apikey
from downapp a, downapikey b
where a.id = b.dappid
and a.id = ${id}$
and a.orgid = ${orgid}$
and b.userid = ${userid}$"""
recs = await sor.sqlExe(sql, ns)
if len(recs):
r = recs[0]
r.apikey = password_decode(r.apikey)
return {
"status":"ok",
"data":r
}
return {
"status": "error",
"data": {
"message": "没有找到用户apikey"
}
}
except Exception as e:
return {
"status": "error",
"data": {
"message": f"{e}"
}
}