Skip to content

Commit

Permalink
fix: 修复自然人关系查询异常
Browse files Browse the repository at this point in the history
  • Loading branch information
neronkl committed Sep 19, 2023
1 parent 24ff4f7 commit 7505a5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/bk-user/bkuser/apis/web/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def get_current_tenant_id(self) -> str:
return tenant_id

def get_current_tenant_user(self) -> TenantUser:
tenant_user = TenantUser.objects.filter(id=self.request.user.id).first()
bk_username = self.request.user.get_property("bk_username")
tenant_user = TenantUser.objects.filter(id=bk_username).first()
if not tenant_user:
raise error_codes.TENANT_USER_NOT_EXIST
return tenant_user
10 changes: 6 additions & 4 deletions src/bk-user/bkuser/biz/natural_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ def get_nature_user_by_tenant_user_id(tenant_user_id: str) -> Optional[NaturalUs
if not tenant_user:
raise error_codes.TENANT_USER_NOT_EXIST

natural_user = DataSourceUserNaturalUserRelation.objects.filter(
natural_user_relation = DataSourceUserNaturalUserRelation.objects.filter(
data_source_user_id=tenant_user.data_source_user_id
).first()
if not natural_user:
if not natural_user_relation:
return None

natural_user = natural_user_relation.natural_user

return NaturalUserInfo(
id=natural_user.id,
full_name=natural_user.name,
full_name=natural_user.full_name,
data_source_user_ids=list(
DataSourceUserNaturalUserRelation.objects.filter(nature_user=natural_user.id).values_list(
DataSourceUserNaturalUserRelation.objects.filter(natural_user=natural_user).values_list(
"data_source_user_id", flat=True
)
),
Expand Down

0 comments on commit 7505a5b

Please sign in to comment.