add tenant logic

This commit is contained in:
2024-12-15 12:28:22 +09:00
parent 2823364148
commit 39775a5179
16 changed files with 138 additions and 55 deletions

View File

@@ -0,0 +1,12 @@
from fastapi import Depends
from app.db.session import get_tenant_db,get_user_db
from app.core import tenantCacheService
def get_db(tenant:str = "1",tenantdb = Depends(get_tenant_db)):
db_url = tenantCacheService.get_tenant_db(tenantdb,tenant)
db = get_user_db(db_url)
try:
yield db
finally:
db.close()