
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
65 lines
1.3 KiB
Python
65 lines
1.3 KiB
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from app.models.membership import PlanType, MembershipStatus
|
|
|
|
|
|
class MembershipPlanBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
plan_type: PlanType
|
|
price: float
|
|
duration_days: int
|
|
features: Optional[str] = None
|
|
|
|
|
|
class MembershipPlanCreate(MembershipPlanBase):
|
|
gym_id: int
|
|
|
|
|
|
class MembershipPlanUpdate(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
plan_type: Optional[PlanType] = None
|
|
price: Optional[float] = None
|
|
duration_days: Optional[int] = None
|
|
features: Optional[str] = None
|
|
|
|
|
|
class MembershipPlanInDB(MembershipPlanBase):
|
|
id: int
|
|
gym_id: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class MembershipPlan(MembershipPlanInDB):
|
|
pass
|
|
|
|
|
|
class GymMembershipBase(BaseModel):
|
|
user_id: int
|
|
gym_id: int
|
|
|
|
|
|
class GymMembershipCreate(GymMembershipBase):
|
|
pass
|
|
|
|
|
|
class GymMembershipInDB(GymMembershipBase):
|
|
id: int
|
|
status: MembershipStatus
|
|
joined_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class GymMembership(GymMembershipInDB):
|
|
pass
|