""" 網路硬碟 Schemas """ from datetime import datetime from typing import Optional from pydantic import Field, ConfigDict from app.schemas.base import BaseSchema, TimestampSchema class NetworkDriveBase(BaseSchema): """網路硬碟基礎 Schema""" quota_gb: int = Field(..., gt=0, description="配額 (GB)") webdav_url: Optional[str] = Field(None, max_length=255, description="WebDAV 路徑") smb_url: Optional[str] = Field(None, max_length=255, description="SMB 路徑") class NetworkDriveCreate(NetworkDriveBase): """創建網路硬碟 Schema""" employee_id: int = Field(..., description="員工 ID") drive_name: str = Field(..., min_length=3, max_length=100, description="NAS 帳號名稱") model_config = ConfigDict( json_schema_extra={ "example": { "employee_id": 1, "drive_name": "porsche.chen", "quota_gb": 200, "webdav_url": "https://nas.lab.taipei/webdav/porsche.chen", "smb_url": "\\\\10.1.0.30\\porsche.chen" } } ) class NetworkDriveUpdate(BaseSchema): """更新網路硬碟 Schema""" quota_gb: Optional[int] = Field(None, gt=0) webdav_url: Optional[str] = Field(None, max_length=255) smb_url: Optional[str] = Field(None, max_length=255) is_active: Optional[bool] = None class NetworkDriveInDB(NetworkDriveBase, TimestampSchema): """資料庫中的網路硬碟 Schema""" id: int employee_id: int drive_name: str is_active: bool model_config = ConfigDict(from_attributes=True) class NetworkDriveResponse(NetworkDriveInDB): """網路硬碟響應 Schema""" employee_name: Optional[str] = Field(None, description="員工姓名") employee_username: Optional[str] = Field(None, description="員工基礎帳號") model_config = ConfigDict( json_schema_extra={ "example": { "id": 1, "employee_id": 1, "drive_name": "porsche.chen", "quota_gb": 200, "webdav_url": "https://nas.lab.taipei/webdav/porsche.chen", "smb_url": "\\\\10.1.0.30\\porsche.chen", "is_active": True, "created_at": "2020-01-01T00:00:00", "updated_at": "2020-01-01T00:00:00", "employee_name": "陳保時", "employee_username": "porsche.chen" } } ) class NetworkDriveListItem(BaseSchema): """網路硬碟列表項 Schema""" id: int drive_name: str quota_gb: int is_active: bool model_config = ConfigDict(from_attributes=True) class NetworkDriveQuotaUpdate(BaseSchema): """更新配額 Schema""" quota_gb: int = Field(..., gt=0, le=1000, description="新配額 (GB)") model_config = ConfigDict( json_schema_extra={ "example": { "quota_gb": 500 } } )