- 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
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, Integer, String, BigInteger, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
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)
|
|
full_name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
language_code: Mapped[str] = mapped_column(String(8), default="ru")
|
|
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()
|
|
)
|
|
|
|
payments: Mapped[list["Payment"]] = relationship(
|
|
back_populates="user", cascade="all, delete-orphan"
|
|
)
|
|
notifications: Mapped[list["Notification"]] = relationship(
|
|
back_populates="user", cascade="all, delete-orphan"
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<User id={self.id} tg={self.telegram_id} {self.username}>"
|