From 314da7ae442f9a5a6c38fe5c6762c66f04a3712a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 31 May 2026 15:36:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Fupapps=E5=92=8Cget=5Forganizations?= =?UTF-8?q?=E7=94=A8=E5=B1=9E=E6=80=A7=E8=AE=BF=E9=97=AE=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E8=AE=BF=E9=97=AE(sqlExe=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/get_organizations.dspy | 23 ++++++++--------------- wwwroot/api/get_upapps.dspy | 21 ++++++++------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/wwwroot/api/get_organizations.dspy b/wwwroot/api/get_organizations.dspy index 71e88ee..cc315ce 100644 --- a/wwwroot/api/get_organizations.dspy +++ b/wwwroot/api/get_organizations.dspy @@ -1,19 +1,12 @@ -#!/usr/bin/env python3 -import json - result = [] -try: - async with get_sor_context(request._run_ns, 'rbac') as sor: - user_orgid = await get_userorgid() - orgs = await sor.R('organization', {'id': user_orgid}) - # Get current org and its children - all_orgs = await sor.sqlExe( - "select id, orgname from organization where id = ${id}$ or parentid = ${id}$ order by orgname", - {'id': user_orgid} - ) - result = [{'value': r['id'], 'text': r['orgname']} for r in (all_orgs or [])] -except Exception as e: - pass +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] return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/get_upapps.dspy b/wwwroot/api/get_upapps.dspy index b75a098..9f35973 100644 --- a/wwwroot/api/get_upapps.dspy +++ b/wwwroot/api/get_upapps.dspy @@ -1,17 +1,12 @@ -#!/usr/bin/env python3 -import json - result = [] -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 where ownerid = ${ownerid}$ or ownerid is null order by name", - {'ownerid': user_orgid} - ) - result = [{'value': r['id'], 'text': r['name']} for r in (apps or [])] -except Exception as e: - pass +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] return json.dumps(result, ensure_ascii=False, default=str)