47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
"""
|
|
발전소 관련 Pydantic 스키마
|
|
- 요청/응답 데이터 검증
|
|
"""
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
|
|
class PlantBase(BaseModel):
|
|
"""발전소 기본 정보 스키마"""
|
|
id: int
|
|
company_id: int
|
|
name: str
|
|
capacity: Optional[float] = Field(None, description="발전 용량 (kW)")
|
|
location: Optional[str] = Field(None, description="발전소 위치")
|
|
created_at: Optional[datetime] = None
|
|
|
|
|
|
class SolarLogBase(BaseModel):
|
|
"""발전 로그 기본 정보 스키마"""
|
|
id: int
|
|
plant_id: int
|
|
timestamp: datetime
|
|
power_output: Optional[float] = Field(None, description="현재 발전량 (kW)")
|
|
daily_generation: Optional[float] = Field(None, description="일일 발전량 (kWh)")
|
|
total_generation: Optional[float] = Field(None, description="누적 발전량 (kWh)")
|
|
|
|
|
|
class PlantWithLatestLog(PlantBase):
|
|
"""발전소 정보 + 최신 발전 현황"""
|
|
latest_log: Optional[SolarLogBase] = Field(None, description="최신 발전 로그")
|
|
|
|
|
|
class PlantResponse(BaseModel):
|
|
"""단일 발전소 응답 스키마"""
|
|
status: str = "success"
|
|
data: PlantWithLatestLog
|
|
|
|
|
|
class PlantsListResponse(BaseModel):
|
|
"""발전소 목록 응답 스키마"""
|
|
status: str = "success"
|
|
data: List[PlantWithLatestLog]
|
|
total_count: int = Field(description="총 발전소 수")
|