Files
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

35 lines
1.2 KiB
Python

import enum
from datetime import datetime
from sqlalchemy import Boolean, DateTime, Enum, Integer, String, Text, BigInteger, func
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class AdminRole(str, enum.Enum):
SUPERADMIN = "superadmin"
MODERATOR = "moderator"
class Admin(Base):
__tablename__ = "admins"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
telegram_id: Mapped[int] = mapped_column(BigInteger, unique=True, nullable=False)
username: Mapped[str | None] = mapped_column(String(64), nullable=True)
role: Mapped[AdminRole] = mapped_column(
Enum(AdminRole, name="admin_role"), default=AdminRole.MODERATOR
)
permissions: Mapped[str | None] = mapped_column(Text, nullable=True)
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now()
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
)
def __repr__(self) -> str:
return f"<Admin id={self.id} tg={self.telegram_id} role={self.role.value}>"