perf(org): 优化获取org_name字段

This commit is contained in:
Bai
2020-11-27 16:58:57 +08:00
committed by Jiangjie.Bai
parent c3b09dd800
commit bbd6cae3d7

View File

@@ -71,7 +71,9 @@ def construct_org_mapper():
default_org = Organization.default()
org_mapper.update({
'': default_org,
Organization.DEFAULT_ID: default_org
Organization.DEFAULT_ID: default_org,
Organization.ROOT_ID: Organization.root(),
Organization.SYSTEM_ID: Organization.system()
})
return org_mapper
@@ -92,9 +94,11 @@ def get_org_name_by_id(org_id):
org_id = str(org_id)
org_mapper = get_org_mapper()
org = org_mapper.get(org_id)
if not org:
org = Organization.objects.filter(id=org_id).first()
return org.name
if org:
org_name = org.name
else:
org_name = 'Not Found'
return org_name
def get_current_org_id_for_serializer():