Files
vpn-control-panel/app/repositories/admin.py
smolkik-code 7c7c88621d Initial commit: VPN Control Panel
- FastAPI REST API with JWT auth
- aiogram 3 Telegram bot with admin middleware
- APScheduler daily tasks (expiry, reminders, revoke, sync)
- SQLAlchemy 2 async ORM with Alembic migrations
- Jinja2 admin panel (Dashboard, Users, Payments, Servers, Tariffs)
- VPN provider abstraction with MockProvider
- Stats service with revenue/subscription analytics
- Docker Compose (PostgreSQL + Redis + app)
- Healthcheck endpoint
2026-07-05 17:50:11 +07:00

20 lines
685 B
Python

from sqlalchemy import select
from app.models.admin import Admin
from app.repositories.base import BaseRepository
class AdminRepository(BaseRepository[Admin]):
def __init__(self, session):
super().__init__(session, Admin)
async def get_by_telegram_id(self, telegram_id: int) -> Admin | None:
stmt = select(Admin).where(Admin.telegram_id == telegram_id)
result = await self.session.execute(stmt)
return result.scalar_one_or_none()
async def get_active_admins(self) -> list[Admin]:
stmt = select(Admin).where(Admin.is_active.is_(True))
result = await self.session.execute(stmt)
return list(result.scalars().all())