Prechádzať zdrojové kódy

fix: 使用 auth.user.tenant_id 查询 enterprise_id

alphah 2 mesiacov pred
rodič
commit
697abbe16b

+ 2 - 1
backend/app/plugin/module_payment/expense/institution/controller.py

@@ -53,7 +53,8 @@ async def create_institution_controller(
     if not enterprise_id:
         from app.plugin.module_payment.enterprise.model import EnterpriseModel
         from sqlalchemy import select
-        stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == auth.tenant_id).limit(1)
+        tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
+        stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
         result = await auth.db.execute(stmt)
         enterprise = result.scalar_one_or_none()
         enterprise_id = enterprise.enterprise_id if enterprise else ""