hulai-admin-api/app/schemas/destination_detail.py
刘涛 8c0a5f489d Initial commit: hulai admin API backend
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 22:01:23 +08:00

36 行
873 B
Python

from __future__ import annotations
from pydantic import BaseModel, field_validator
class DestinationDetailSchema(BaseModel):
name: str
slug: str
subtitle: str | None = None
cover_image: str | None = None
description: str | None = None
location: str | None = None
best_season: str | None = None
duration: str | None = None
highlights: list = []
gallery: list = []
tags: list = []
is_visible: bool = True
@field_validator('highlights', 'gallery', 'tags', mode='before')
@classmethod
def coerce_none_to_list(cls, v):
return v if v is not None else []
class DestinationDetailResponse(DestinationDetailSchema):
id: int
sort_order: int = 0
class Config:
from_attributes = True
class DestinationDetailListResponse(BaseModel):
items: list[DestinationDetailResponse]
total: int