Обновление приложения
This commit is contained in:
48
backend/app/schemas/currency.py
Normal file
48
backend/app/schemas/currency.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class CurrencyCreate(BaseModel):
|
||||
code: str = Field(..., min_length=3, max_length=3)
|
||||
name: str = Field(..., max_length=100)
|
||||
symbol: str | None = Field(None, max_length=10)
|
||||
is_active: bool = True
|
||||
|
||||
|
||||
class CurrencyUpdate(BaseModel):
|
||||
name: str | None = Field(None, max_length=100)
|
||||
symbol: str | None = Field(None, max_length=10)
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class CurrencyOut(BaseModel):
|
||||
id: int
|
||||
code: str
|
||||
name: str
|
||||
symbol: str | None = None
|
||||
is_active: bool
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ExchangeRateCreate(BaseModel):
|
||||
currency_from_id: int
|
||||
currency_to_id: int
|
||||
rate: Decimal = Field(..., gt=0)
|
||||
rate_date: date
|
||||
source: str | None = None
|
||||
|
||||
|
||||
class ExchangeRateOut(BaseModel):
|
||||
id: int
|
||||
currency_from_id: int
|
||||
currency_to_id: int
|
||||
rate: Decimal
|
||||
rate_date: date
|
||||
source: str | None = None
|
||||
created_at: datetime
|
||||
currency_from: CurrencyOut
|
||||
currency_to: CurrencyOut
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user