from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List

# Project Schemas (project_name 추가)
class ProjectBase(BaseModel):
    official_project_code: str = Field(..., description="공식 프로젝트 코드")
    project_name: str = Field(..., description="프로젝트명")  # 추가
    design_project_code: Optional[str] = Field(None, description="설계 프로젝트 코드")
    is_code_matched: bool = Field(False, description="코드 매칭 여부")
    status: str = Field("active", description="프로젝트 상태")

class ProjectCreate(ProjectBase):
    pass

class ProjectResponse(ProjectBase):
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

# File Schemas (기존 유지)
class FileResponse(BaseModel):
    id: int
    filename: str
    original_filename: str
    file_path: str
    project_id: int
    project_code: Optional[str] = None
    revision: str = "Rev.0"
    description: Optional[str] = None
    upload_date: datetime
    parsed_count: int = 0
    is_active: bool = True

    class Config:
        from_attributes = True

class FileUploadResponse(BaseModel):
    success: bool
    message: str
    file_id: int
    filename: str
    parsed_materials_count: int
    file_path: str
