39 行
979 B
Python
39 行
979 B
Python
from __future__ import annotations
|
|
from pydantic import BaseModel
|
|
from typing import Literal
|
|
|
|
|
|
class CustomizeSubmissionResponse(BaseModel):
|
|
id: int
|
|
name: str | None = None
|
|
phone: str | None = None
|
|
wechat: str | None = None
|
|
adults: int = 0
|
|
children: int = 0
|
|
travel_dates: str | None = None
|
|
budget: str | None = None
|
|
interests: list = []
|
|
notes: str | None = None
|
|
source: str | None = None
|
|
status: str = "pending"
|
|
created_at: str | None = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
@classmethod
|
|
def model_validate(cls, obj, **kwargs):
|
|
data = super().model_validate(obj, **kwargs)
|
|
if obj.created_at:
|
|
data.created_at = obj.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
return data
|
|
|
|
|
|
class CustomizeSubmissionListResponse(BaseModel):
|
|
items: list[CustomizeSubmissionResponse]
|
|
total: int
|
|
|
|
|
|
class CustomizeStatusUpdate(BaseModel):
|
|
status: Literal["pending", "processed"]
|