feat: Service API - add end-user lookup endpoint (#32015)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
盐粒 Yanli
2026-02-09 14:01:22 +08:00
committed by yyh
parent 6f50915d2b
commit a303560b98
21 changed files with 986 additions and 4 deletions

View File

@ -16,6 +16,25 @@ class EndUserService:
Service for managing end users.
"""
@classmethod
def get_end_user_by_id(cls, *, tenant_id: str, app_id: str, end_user_id: str) -> EndUser | None:
"""Get an end user by primary key.
This is scoped to the provided tenant and app to prevent cross-tenant/app access
when an end-user ID is known.
"""
with Session(db.engine, expire_on_commit=False) as session:
return (
session.query(EndUser)
.where(
EndUser.id == end_user_id,
EndUser.tenant_id == tenant_id,
EndUser.app_id == app_id,
)
.first()
)
@classmethod
def get_or_create_end_user(cls, app_model: App, user_id: str | None = None) -> EndUser:
"""