61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PromotionOut(BaseModel):
|
|
id: int
|
|
title: str
|
|
image_url: str
|
|
link_type: str = "spot"
|
|
link_id: int | None = None
|
|
link_url: str | None = None
|
|
position: str = "home_banner"
|
|
sort_order: int = 0
|
|
spot_id: int | None = None
|
|
event_id: int | None = None
|
|
shooting_id: int | None = None
|
|
start_time: datetime | None = None
|
|
end_time: datetime | None = None
|
|
is_active: bool = True
|
|
impressions: int = 0
|
|
clicks: int = 0
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class PromotionClick(BaseModel):
|
|
promotion_id: int
|
|
|
|
|
|
class PromotionCreate(BaseModel):
|
|
title: str = Field(min_length=1, max_length=200)
|
|
image_url: str = Field(min_length=1, max_length=500)
|
|
link_type: str = Field(pattern="^(spot|event|shooting|url)$")
|
|
link_id: int | None = None
|
|
spot_id: int | None = None
|
|
event_id: int | None = None
|
|
shooting_id: int | None = None
|
|
link_url: str | None = Field(default=None, max_length=500)
|
|
position: str = Field(default="home_banner", min_length=1, max_length=30)
|
|
sort_order: int = 0
|
|
start_time: datetime | None = None
|
|
end_time: datetime | None = None
|
|
is_active: bool = True
|
|
|
|
|
|
class PromotionUpdate(BaseModel):
|
|
title: str | None = Field(default=None, min_length=1, max_length=200)
|
|
image_url: str | None = Field(default=None, min_length=1, max_length=500)
|
|
link_type: str | None = Field(default=None, pattern="^(spot|event|shooting|url)$")
|
|
link_id: int | None = None
|
|
spot_id: int | None = None
|
|
event_id: int | None = None
|
|
shooting_id: int | None = None
|
|
link_url: str | None = Field(default=None, max_length=500)
|
|
position: str | None = Field(default=None, min_length=1, max_length=30)
|
|
sort_order: int | None = None
|
|
start_time: datetime | None = None
|
|
end_time: datetime | None = None
|
|
is_active: bool | None = None
|