feat: add full project - backend, frontend, docker, specs and configs
This commit is contained in:
parent
b77c7d5a01
commit
e6cb06255b
24489 changed files with 61341 additions and 36 deletions
95
backend/app/schemas/client_area.py
Normal file
95
backend/app/schemas/client_area.py
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
from pydantic import BaseModel, field_validator
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
import uuid
|
||||
|
||||
|
||||
class PropertyBrief(BaseModel):
|
||||
id: str
|
||||
title: str
|
||||
slug: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class SavedPropertyOut(BaseModel):
|
||||
id: str
|
||||
property_id: Optional[str]
|
||||
property: Optional[PropertyBrief]
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class FavoriteIn(BaseModel):
|
||||
property_id: str
|
||||
|
||||
@field_validator("property_id")
|
||||
@classmethod
|
||||
def validate_uuid(cls, v: str) -> str:
|
||||
try:
|
||||
uuid.UUID(v)
|
||||
except ValueError:
|
||||
raise ValueError("property_id deve ser um UUID válido")
|
||||
return v
|
||||
|
||||
|
||||
class VisitRequestOut(BaseModel):
|
||||
id: str
|
||||
property: Optional[PropertyBrief]
|
||||
message: Optional[str]
|
||||
status: str
|
||||
scheduled_at: Optional[datetime]
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class VisitStatusIn(BaseModel):
|
||||
status: str
|
||||
scheduled_at: Optional[datetime] = None
|
||||
|
||||
@field_validator("status")
|
||||
@classmethod
|
||||
def validate_status(cls, v: str) -> str:
|
||||
allowed = {"pending", "confirmed", "cancelled", "completed"}
|
||||
if v not in allowed:
|
||||
raise ValueError(f'Status deve ser um de: {", ".join(allowed)}')
|
||||
return v
|
||||
|
||||
|
||||
class BoletoOut(BaseModel):
|
||||
id: str
|
||||
property: Optional[PropertyBrief]
|
||||
description: str
|
||||
amount: Decimal
|
||||
due_date: date
|
||||
status: str
|
||||
url: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class BoletoCreateIn(BaseModel):
|
||||
user_id: str
|
||||
property_id: Optional[str] = None
|
||||
description: str
|
||||
amount: Decimal
|
||||
due_date: date
|
||||
url: Optional[str] = None
|
||||
|
||||
@field_validator("description")
|
||||
@classmethod
|
||||
def description_not_empty(cls, v: str) -> str:
|
||||
if not v.strip():
|
||||
raise ValueError("Descrição não pode ser vazia")
|
||||
return v.strip()
|
||||
|
||||
@field_validator("amount")
|
||||
@classmethod
|
||||
def amount_positive(cls, v: Decimal) -> Decimal:
|
||||
if v <= 0:
|
||||
raise ValueError("Valor deve ser positivo")
|
||||
return v
|
||||
Loading…
Add table
Add a link
Reference in a new issue