from sqlalchemy import select
class TenantBaseRepository:
    def __init__(self, session, model): self.session, self.model = session, model
    async def add(self, entity):
        self.session.add(entity); await self.session.flush(); return entity
    async def get(self, tenant_id, entity_id):
        return (await self.session.execute(select(self.model).where(self.model.tenant_id==tenant_id,self.model.id==entity_id))).scalar_one_or_none()
    async def list(self, tenant_id):
        return (await self.session.execute(select(self.model).where(self.model.tenant_id==tenant_id))).scalars().all()
