
Create a complete e-commerce application with the following features: - User authentication and authorization - Product and category management - Shopping cart functionality - Order processing - Database migrations with Alembic - Comprehensive documentation
33 lines
627 B
Python
33 lines
627 B
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class CategoryBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class CategoryCreate(CategoryBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class CategoryUpdate(CategoryBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
class CategoryInDBBase(CategoryBase):
|
|
id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Category(CategoryInDBBase):
|
|
pass |