Files
o2o-weather/backend/router/v1/feed/protocol.py
T
minaChoiandClaude Opus 5.5 e134295ce5 feat: 날씨각 백엔드 API (날씨·노을·지수·주말·계절·피드·로그인·반응)
- FastAPI + PostgreSQL + Redis, web·worker 분리, compose 에 backend·worker·postgres·redis 추가
- 기상청 단기·초단기·중기·특보, 에어코리아, Open-Meteo, TourAPI, 특일정보 연동 (첫 조회 때 받고 캐시)
- 매일 03:00 worker 가 전국 공통 피드 칸을 정하고 지난 데이터를 정리
- 시드: 시군구 256곳, 지수 23개, 노을 대표 지점·명소, 데이트 명소, 읽을거리
- pytest 66개 (테스트 전용 DB·Redis 사용)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:32:22 +09:00

152 lines
3.0 KiB
Python

from datetime import date, datetime
from typing import Annotated, Literal, Optional, Union
from pydantic import Field
from common.enums import PostType, SlotTone
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
class Row(WebPacketProtocol):
label: str
value: str
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] = []
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]
class WeekDay(WebPacketProtocol):
day: date
weekday: str
icon: str
text: str
class WeekSlide(WebPacketProtocol):
kind: Literal["week"]
eyebrow: str
line: str
days: list[WeekDay]
Slide = Annotated[Union[HoursSlide, RowsSlide, GakSlide, SunsetSlide, WeekSlide], 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
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
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
top3: list[TopIndex] = []
bubble: Optional[str] = None
class BandEvent(WebPacketProtocol):
event_id: int
name: str
status_label: str
icon: str
class BandArticle(WebPacketProtocol):
article_id: int
title: str
meta: str
icon: str
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
hero: Optional[Hero] = None
stories: list[TopIndex] = []
posts: list[PostData] = []
bands: Optional[Bands] = None
class Res_Post(Res_WebPacketProtocol):
post: Optional[PostData] = None