"""
项目全部信息的增删查改模板，聚合了项目相关schema
"""

from pydantic import BaseModel, Field, field_serializer
from typing import Optional
from .project_base import (
    ProjectResponseBase,
    ProjectEnsureCapacity,
    ProjectClimbCapacity,
    ProjectChallengeCapacity,
    ProjectActualConstruction,
    ProjectPlanConstruction,
    ProjectInvestmentDecision,
    ProjectKeyConstraints,
    ProjectProductionCapacity,
    ProjectCompleteInvestment,
    ProjectDynamicInvestment
)
from ..project_extensions.preparation import PreparationDetail
from ..project_extensions.production import ProductionDetail
from ..project_extensions.project_detail import ProjectDetailProject
from ..project_extensions.generator_unit import (
    GeneratorUnitProject,
    PostGeneratorUnits
)
from ..project_extensions.lar import (
    LarDetailSchema,
    LarChangeListSchema,
    LarChangeUpdateSchema,
    LarMainInfoUpdateSchema,
    LarResettlementSchema,
    LarInvestmentSchema, LarChangeDetailSchema
)
from ..project_extensions.contract_change import (
    ContractChangeResponse,
    PostContractChange
)

from ..project_multi_type import (
    PhotovoltaicExtension,
    OnShoreWindExtension,
    OffShoreWindExtension,
    HydropowerExtension,
    PumpedStorageExtension,
    GasTurbineExtension,
    ThermalPowerExtension
)


class ProjectInfoResponse(BaseModel):
    """
    项目全部信息响应模型
    """

    project: ProjectResponseBase = Field(..., description="项目基本信息")
    project_detail: list[ProjectDetailProject] = Field(..., description="项目容量信息")
    generator_units: list[GeneratorUnitProject] = Field(..., description="发电单元信息列表(仅限水电、抽蓄、煤电、气电)")
    lar: Optional[LarDetailSchema] = Field(None, description="移民征地信息(仅限水电、抽蓄)")
    lar_change: list[LarChangeDetailSchema] = Field(default_factory=list, description="移民变更信息列表(仅限水电、抽蓄)")
    contract_changes: list[ContractChangeResponse] = Field(..., description="合同变更信息列表(仅限水电、抽蓄、煤电、气电)")

    # 扩展字段
    photovoltaic_extension: PhotovoltaicExtension | None = Field(None, description="光伏项目扩展信息")
    onshore_wind_extension: OnShoreWindExtension | None = Field(None, description="陆风项目扩展信息")
    offshore_wind_extension: OffShoreWindExtension | None = Field(None, description="海风项目扩展信息")
    hydropower_extension: HydropowerExtension | None = Field(None, description="水电项目扩展信息")
    pumped_storage_extension: PumpedStorageExtension | None = Field(None, description="抽蓄项目扩展信息")
    gas_turbine_extension: GasTurbineExtension | None = Field(None, description="燃气轮机项目扩展信息")
    thermal_power_extension: ThermalPowerExtension | None = Field(None, description="火电项目扩展信息")

    # 投产节点
    production_list: list[ProductionDetail] = Field(default_factory=list, description="投产节点列表")
    # 里程碑节点
    preparation_list: list[PreparationDetail] = Field(default_factory=list, description="里程碑节点列表")


class ProjectListResponse(BaseModel):
    """
    项目列表模型:分页
    """
    page: int
    page_size: int
    total: int
    list: list[ProjectInfoResponse]
