from fastapi import APIRouter, Depends, HTTPException, Request, UploadFile, File
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from typing import Optional, List
from datetime import datetime, timezone
from pydantic import BaseModel
from typing import Optional, Any, Union




class BatchEnterRequest(BaseModel):
    ids: list[Union[int, str]]
    table_type: Optional[str] = None

class BatchDeleteRequest(BaseModel):
    ids: list[Union[int, str]]
    table_type: Optional[str] = None

class ConvertRequest(BaseModel):
    id: Union[int, str]
    table_type: Optional[str] = None



class DocumentAdd(BaseModel):
    title: str
    content: str
    primary_category_id: Optional[Any] = None
    secondary_category_id: Optional[Any] = None
    year: Optional[int] = None
    table_type: Optional[str] = "basis"
    # 新增编辑需要的字段
    id: Optional[str] = None
    source_id: Optional[str] = None
    # 扩展字段 (子表特有属性)
    standard_no: Optional[str] = None
    issuing_authority: Optional[str] = None
    release_date: Optional[str] = None
    document_type: Optional[str] = None
    professional_field: Optional[str] = None
    validity: Optional[str] = None
    project_name: Optional[str] = None
    project_section: Optional[str] = None
    # 文件相关字段
    file_url: Optional[str] = None
    json_url: Optional[str] = None
    file_extension: Optional[str] = None

class DocumentListRequest(BaseModel):
    page: int = 1
    size: int = 50
    keyword: Optional[str] = None
    table_type: Optional[str] = None
    whether_to_enter: Optional[int] = None

class UploadUrlRequest(BaseModel):
    filename: str
    content_type: str

class UploadUrlResponse(BaseModel):
    upload_url: str
    file_url: str
    object_name: str