From 37c6814b2d7c965d990c0aec9a28ec8806b68141 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 31 May 2026 15:41:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4get=5Forganizations?= =?UTF-8?q?=E7=9A=84=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=89=80=E6=9C=89=E7=BB=84=E7=BB=87=EF=BC=9B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/get_organizations.dspy | 21 ++++++++++++--------- wwwroot/api/get_upapps.dspy | 22 +++++++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) 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)