"""
能力评估相关的Pydantic Schema
"""
from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime


class AbilityDimension(BaseModel):
    """能力维度评分"""
    name: str = Field(..., description="能力维度名称")
    score: int = Field(..., ge=0, le=100, description="评分(0-100)")
    feedback: str = Field(..., description="反馈建议")


class CourseRecommendation(BaseModel):
    """课程推荐"""
    course_id: int = Field(..., description="课程ID")
    course_name: str = Field(..., description="课程名称")
    recommendation_reason: str = Field(..., description="推荐理由")
    priority: str = Field(..., description="优先级: high/medium/low")
    match_score: int = Field(..., ge=0, le=100, description="匹配度(0-100)")


class AbilityAssessmentResponse(BaseModel):
    """能力评估响应"""
    assessment_id: int = Field(..., description="评估记录ID")
    total_score: int = Field(..., ge=0, le=100, description="综合评分")
    dimensions: List[AbilityDimension] = Field(..., description="能力维度列表")
    recommended_courses: List[CourseRecommendation] = Field(..., description="推荐课程列表")
    conversation_count: int = Field(..., description="分析的对话数量")
    analyzed_at: Optional[datetime] = Field(None, description="分析时间")


class AbilityAssessmentHistory(BaseModel):
    """能力评估历史记录"""
    id: int
    user_id: int
    source_type: str
    source_id: Optional[str]
    total_score: Optional[int]
    ability_dimensions: List[AbilityDimension]
    recommended_courses: Optional[List[CourseRecommendation]]
    conversation_count: Optional[int]
    analyzed_at: datetime
    created_at: datetime
    
    class Config:
        from_attributes = True

