
- Set up project structure and FastAPI application - Create database models for users, products, and inventory - Configure SQLAlchemy and Alembic for database management - Implement JWT authentication - Create API endpoints for user, product, and inventory management - Add admin-only routes and authorization middleware - Add health check endpoint - Update README with documentation - Lint and fix code issues
59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
from app.models.user import UserRole
|
|
|
|
|
|
# Shared properties
|
|
class UserBase(BaseModel):
|
|
"""Base user schema."""
|
|
email: Optional[EmailStr] = None
|
|
username: Optional[str] = None
|
|
full_name: Optional[str] = None
|
|
is_active: Optional[bool] = True
|
|
role: Optional[UserRole] = UserRole.CUSTOMER
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class UserCreate(BaseModel):
|
|
"""User creation schema."""
|
|
email: EmailStr
|
|
username: str
|
|
password: str
|
|
full_name: Optional[str] = None
|
|
role: Optional[UserRole] = UserRole.CUSTOMER
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class UserUpdate(BaseModel):
|
|
"""User update schema."""
|
|
email: Optional[EmailStr] = None
|
|
username: Optional[str] = None
|
|
password: Optional[str] = None
|
|
full_name: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
role: Optional[UserRole] = None
|
|
|
|
|
|
# Properties to return to client
|
|
class User(UserBase):
|
|
"""User schema to return to client."""
|
|
id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
"""Configuration for the schema."""
|
|
from_attributes = True
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class UserInDB(User):
|
|
"""User schema for database."""
|
|
hashed_password: str
|
|
|
|
class Config:
|
|
"""Configuration for the schema."""
|
|
from_attributes = True |