197 lines
5.2 KiB
Python
197 lines
5.2 KiB
Python
from datetime import date, datetime
|
|
from typing import Annotated, Literal, Optional, Union
|
|
|
|
from pydantic import Field
|
|
|
|
from common.enums import PostType, SkySituation, SlotTone
|
|
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
|
|
|
|
|
|
class Row(WebPacketProtocol):
|
|
label: str
|
|
value: str
|
|
place: Optional[str] = Field(default=None, description="위치가 정해진 장소면 지도에서 찾을 이름 (앱이 네이버 지도 링크를 건다)")
|
|
|
|
|
|
class HourCell(WebPacketProtocol):
|
|
label: str
|
|
icon: str
|
|
temp_c: Optional[float] = None
|
|
tone: SlotTone
|
|
|
|
|
|
class HoursSlide(WebPacketProtocol):
|
|
kind: Literal["hours"]
|
|
eyebrow: str
|
|
line: str
|
|
hours: list[HourCell]
|
|
|
|
|
|
class RowsSlide(WebPacketProtocol):
|
|
"""우산·미세먼지·계절 소식·행사·상식처럼 '한 줄 + 표' 모양."""
|
|
|
|
kind: Literal["rows"]
|
|
eyebrow: str
|
|
line: str
|
|
icon: str
|
|
rows: list[Row] = []
|
|
image: Optional[str] = None # 있으면 아이콘 대신 카드 전체에 사진
|
|
image_credit: Optional[str] = None # 사진 출처 표기 ("ⓒ한국관광공사")
|
|
|
|
|
|
class GakSlide(WebPacketProtocol):
|
|
kind: Literal["gak"]
|
|
index_id: int
|
|
code: str
|
|
name: str
|
|
rank: int
|
|
score: int
|
|
line: str
|
|
summary: str
|
|
|
|
|
|
class Cut(WebPacketProtocol):
|
|
at: datetime
|
|
kind: str
|
|
label: str
|
|
|
|
|
|
class SunsetSlide(WebPacketProtocol):
|
|
kind: Literal["sunset"]
|
|
eyebrow: str
|
|
line: str
|
|
score: int
|
|
grade_label: str
|
|
cuts: list[Cut]
|
|
situation: Optional[SkySituation] = Field(default=None, description="하늘 상황. 앱이 카드 하늘 색을 고른다")
|
|
|
|
|
|
class WeekDay(WebPacketProtocol):
|
|
day: date
|
|
weekday: str
|
|
icon: str
|
|
text: str
|
|
temp_min_c: Optional[float] = None
|
|
temp_max_c: Optional[float] = None
|
|
rain_prob: Optional[int] = None
|
|
|
|
|
|
class WeekSlide(WebPacketProtocol):
|
|
"""주말 예보: 토·일 비교 + 옷차림·우산 팁."""
|
|
|
|
kind: Literal["week"]
|
|
eyebrow: str
|
|
line: str
|
|
days: list[WeekDay]
|
|
tip: Optional[str] = None
|
|
|
|
|
|
class PlanStep(WebPacketProtocol):
|
|
time: str
|
|
icon: str
|
|
title: str
|
|
sub: str
|
|
image: Optional[str] = None # 행사 사진
|
|
image_credit: Optional[str] = None
|
|
|
|
|
|
class PlanSlide(WebPacketProtocol):
|
|
"""주말 플랜: 그날 시간대별 동선."""
|
|
|
|
kind: Literal["plan"]
|
|
eyebrow: str
|
|
line: str
|
|
steps: list[PlanStep]
|
|
|
|
|
|
Slide = Annotated[Union[HoursSlide, RowsSlide, GakSlide, SunsetSlide, WeekSlide, PlanSlide], Field(discriminator="kind")]
|
|
|
|
|
|
class PostData(WebPacketProtocol):
|
|
post_id: int
|
|
post_type: PostType
|
|
title: str
|
|
icon: str
|
|
caption: str
|
|
slides: list[Slide]
|
|
share_messages: list[str] = []
|
|
like_count: int
|
|
comment_count: int
|
|
published_at: datetime
|
|
size: Literal["full", "line"] = "full" # line: 한 줄 카드 (흐린 날 노을)
|
|
liked: Optional[bool] = None
|
|
saved: Optional[bool] = None
|
|
|
|
|
|
class TopIndex(WebPacketProtocol):
|
|
index_id: int
|
|
code: str
|
|
name: str
|
|
icon: str
|
|
score: int
|
|
rank: int
|
|
summary: Optional[str] = None
|
|
active: bool = Field(default=True, description="지금 구간이 이 각의 시간대와 겹침. false 면 순위 밖, score 는 하루 점수")
|
|
|
|
|
|
class HeroStat(WebPacketProtocol):
|
|
icon: str
|
|
label: str
|
|
value: str
|
|
tone: Literal["normal", "warn", "rain"] = Field(description="normal=기본, warn=조심(노랑), rain=비(파랑)")
|
|
|
|
|
|
class Hero(WebPacketProtocol):
|
|
now_at: datetime
|
|
sky_mode: Literal["morning", "day", "sunset", "night"]
|
|
temp_c: Optional[float] = None
|
|
feels_c: Optional[float] = None
|
|
discomfort: Optional[int] = None
|
|
discomfort_label: Optional[str] = None
|
|
rain_2h_text: Optional[str] = None
|
|
will_rain_2h: Optional[bool] = None
|
|
weather_score: Optional[int] = None
|
|
top1: Optional[TopIndex] = None
|
|
bubble: Optional[str] = None
|
|
moon_name: Optional[str] = Field(default=None, description="오늘 밤 달 모양: 삭·초승달·상현달·차오르는 달·보름달·기우는 달·하현달·그믐달")
|
|
moon_pct: Optional[int] = Field(default=None, description="달이 밝게 보이는 비율 0~100")
|
|
stats: list[HeroStat] = Field(default_factory=list, description="히어로 두 칸. 지금 챙길 것(비·미세먼지·자외선·일교차·체감·불쾌지수) 먼저")
|
|
|
|
|
|
class BandEvent(WebPacketProtocol):
|
|
event_id: int
|
|
name: str
|
|
status_label: str
|
|
icon: str
|
|
image: Optional[str] = None
|
|
image_credit: Optional[str] = None
|
|
|
|
|
|
class BandArticle(WebPacketProtocol):
|
|
article_id: int
|
|
title: str
|
|
meta: str
|
|
icon: str
|
|
image: Optional[str] = None
|
|
image_credit: Optional[str] = None
|
|
|
|
|
|
class Bands(WebPacketProtocol):
|
|
events: list[BandEvent] = []
|
|
top5: list[TopIndex] = []
|
|
season: list[BandArticle] = []
|
|
|
|
|
|
class Res_Feed(Res_WebPacketProtocol):
|
|
region_code: Optional[str] = None
|
|
region_name: Optional[str] = None
|
|
slot: Optional[Literal["morning", "day", "evening", "night"]] = None # 피드 순서를 정한 시간대
|
|
hero: Optional[Hero] = None
|
|
stories: list[TopIndex] = []
|
|
posts: list[PostData] = []
|
|
bands: Optional[Bands] = None
|
|
|
|
|
|
class Res_Post(Res_WebPacketProtocol):
|
|
post: Optional[PostData] = None
|