""" 项目相关的 Pydantic Schema """ from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from app.models.project import ProjectMemberRole class ProjectBase(BaseModel): """项目基础 Schema""" name: str = Field(..., min_length=1, max_length=100, description="项目名称") description: Optional[str] = Field(None, max_length=500, description="项目描述") is_public: int = Field(0, description="是否公开:0-私有 1-公开") class ProjectCreate(ProjectBase): """创建项目 Schema""" pass class ProjectUpdate(BaseModel): """更新项目 Schema""" name: Optional[str] = Field(None, min_length=1, max_length=100) description: Optional[str] = None is_public: Optional[int] = None cover_image: Optional[str] = None status: Optional[int] = None class ProjectResponse(ProjectBase): """项目响应 Schema""" id: int storage_key: str owner_id: int is_template: int status: int cover_image: Optional[str] = None visit_count: int created_at: datetime updated_at: datetime class Config: from_attributes = True class ProjectMemberAdd(BaseModel): """添加项目成员 Schema""" user_id: int = Field(..., description="用户ID") role: ProjectMemberRole = Field(ProjectMemberRole.VIEWER, description="项目角色") class ProjectMemberUpdate(BaseModel): """更新项目成员 Schema""" role: ProjectMemberRole = Field(..., description="项目角色") class ProjectMemberResponse(BaseModel): """项目成员响应 Schema""" id: int project_id: int user_id: int role: ProjectMemberRole joined_at: datetime class Config: from_attributes = True class ProjectShareSettings(BaseModel): """项目分享设置 Schema""" access_pass: Optional[str] = Field(None, max_length=100, description="访问密码(None表示取消密码)") class ProjectShareInfo(BaseModel): """项目分享信息响应 Schema""" share_url: str = Field(..., description="分享链接") has_password: bool = Field(..., description="是否设置了访问密码") access_pass: Optional[str] = Field(None, description="访问密码(仅项目所有者可见)")