diff --git a/wwwroot/api/get_organizations.dspy b/wwwroot/api/get_organizations.dspy index cc315ce..5cc13eb 100644 --- a/wwwroot/api/get_organizations.dspy +++ b/wwwroot/api/get_organizations.dspy @@ -1,12 +1,15 @@ result = [] -async with get_sor_context(request._run_ns, 'rbac') as sor: - user_orgid = await get_userorgid() - all_orgs = await sor.sqlExe( - "select id, orgname from organization where id = ${id}$ or parentid = ${id}$ order by orgname", - {'id': user_orgid} - ) - if all_orgs: - result = [{'value': r.id, 'text': r.orgname} for r in all_orgs] +try: + async with get_sor_context(request._run_ns, 'rbac') as sor: + orgs = await sor.sqlExe( + "select id, orgname from organization order by orgname", + {} + ) + if orgs: + for r in orgs: + result.append({'value': str(r.id), 'text': r.orgname or ''}) +except Exception as e: + debug(f'get_organizations error: {e}') -return json.dumps(result, ensure_ascii=False, default=str) +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/get_upapps.dspy b/wwwroot/api/get_upapps.dspy index 9f35973..f408bd7 100644 --- a/wwwroot/api/get_upapps.dspy +++ b/wwwroot/api/get_upapps.dspy @@ -1,12 +1,16 @@ result = [] -async with get_sor_context(request._run_ns, 'uapi') as sor: - user_orgid = await get_userorgid() - apps = await sor.sqlExe( - "select id, name from upapp where ownerid = ${ownerid}$ or ownerid is null order by name", - {'ownerid': user_orgid} - ) - if apps: - result = [{'value': r.id, 'text': r.name} for r in apps] +try: + async with get_sor_context(request._run_ns, 'uapi') as sor: + user_orgid = await get_userorgid() + apps = await sor.sqlExe( + "select id, name from upapp order by name", + {} + ) + if apps: + for r in apps: + result.append({'value': str(r.id), 'text': r.name or ''}) +except Exception as e: + debug(f'get_upapps error: {e}') -return json.dumps(result, ensure_ascii=False, default=str) +return json.dumps(result, ensure_ascii=False)