
Features: - User registration and authentication with JWT tokens - Multi-level admin access (Admin and Super Admin) - Gym management with membership plans - Subscription management with payment integration - Stripe and Paystack payment gateway support - Role-based access control - SQLite database with Alembic migrations - Comprehensive API endpoints with FastAPI - Database models for users, gyms, memberships, subscriptions, and transactions - Admin endpoints for user management and financial reporting - Health check and documentation endpoints Core Components: - FastAPI application with CORS support - SQLAlchemy ORM with relationship mapping - JWT-based authentication with bcrypt password hashing - Payment service abstraction for multiple gateways - Pydantic schemas for request/response validation - Alembic database migration system - Admin dashboard functionality - Environment variable configuration
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Enum
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
import enum
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class UserRole(str, enum.Enum):
|
|
USER = "user"
|
|
ADMIN = "admin"
|
|
SUPER_ADMIN = "super_admin"
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
full_name = Column(String, nullable=False)
|
|
phone = Column(String, nullable=True)
|
|
hashed_password = Column(String, nullable=False)
|
|
role = Column(Enum(UserRole), default=UserRole.USER, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
gym_memberships = relationship("GymMembership", back_populates="user")
|
|
subscriptions = relationship("Subscription", back_populates="user")
|
|
transactions = relationship("Transaction", back_populates="user")
|
|
invited_by = Column(Integer, nullable=True)
|