package model

import "time"

// WritingCorrection 写作批改结果
type WritingCorrection struct {
	ID             uint                 `json:"id" gorm:"primaryKey"`
	UserID         uint                 `json:"user_id"`
	Content        string               `json:"content"`
	TaskType       string               `json:"task_type"`
	OverallScore   int                  `json:"overall_score"`
	GrammarScore   int                  `json:"grammar_score"`
	VocabularyScore int                 `json:"vocabulary_score"`
	StructureScore int                  `json:"structure_score"`
	ContentScore   int                  `json:"content_score"`
	Corrections    []WritingError       `json:"corrections"`
	Suggestions    []string             `json:"suggestions" gorm:"type:json"`
	Strengths      []string             `json:"strengths" gorm:"type:json"`
	Weaknesses     []string             `json:"weaknesses" gorm:"type:json"`
	CreatedAt      time.Time            `json:"created_at"`
	UpdatedAt      time.Time            `json:"updated_at"`
}

// WritingError 写作错误
type WritingError struct {
	ID           uint   `json:"id" gorm:"primaryKey"`
	CorrectionID uint   `json:"correction_id"`
	Original     string `json:"original"`
	Corrected    string `json:"corrected"`
	Explanation  string `json:"explanation"`
	ErrorType    string `json:"error_type"` // grammar, vocabulary, structure, etc.
}

// SpeakingEvaluation 口语评估结果
type SpeakingEvaluation struct {
	ID                 uint      `json:"id" gorm:"primaryKey"`
	UserID             uint      `json:"user_id"`
	AudioText          string    `json:"audio_text"`
	Prompt             string    `json:"prompt"`
	OverallScore       int       `json:"overall_score"`
	PronunciationScore int       `json:"pronunciation_score"`
	FluencyScore       int       `json:"fluency_score"`
	GrammarScore       int       `json:"grammar_score"`
	VocabularyScore    int       `json:"vocabulary_score"`
	Feedback           string    `json:"feedback"`
	Strengths          []string  `json:"strengths" gorm:"type:json"`
	Improvements       []string  `json:"improvements" gorm:"type:json"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

// AIRecommendation AI推荐
type AIRecommendation struct {
	ID                uint      `json:"id" gorm:"primaryKey"`
	UserID            uint      `json:"user_id"`
	UserLevel         string    `json:"user_level"`
	RecommendedTopics []string  `json:"recommended_topics" gorm:"type:json"`
	DifficultyLevel   string    `json:"difficulty_level"`
	StudyPlan         []string  `json:"study_plan" gorm:"type:json"`
	FocusAreas        []string  `json:"focus_areas" gorm:"type:json"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

// Exercise 练习题
type Exercise struct {
	ID           uint       `json:"id" gorm:"primaryKey"`
	Title        string     `json:"title"`
	Instructions string     `json:"instructions"`
	Content      string     `json:"content"`
	ExerciseType string     `json:"exercise_type"`
	Questions    []Question `json:"questions"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
}

// Question 问题
type Question struct {
	ID            uint     `json:"id" gorm:"primaryKey"`
	ExerciseID    uint     `json:"exercise_id"`
	Question      string   `json:"question"`
	Options       []string `json:"options" gorm:"type:json"`
	CorrectAnswer string   `json:"correct_answer"`
	Explanation   string   `json:"explanation"`
}

// AIRequest AI请求记录
type AIRequest struct {
	ID          uint      `json:"id" gorm:"primaryKey"`
	UserID      uint      `json:"user_id"`
	RequestType string    `json:"request_type"` // writing_correction, speaking_evaluation, recommendation, exercise_generation
	Prompt      string    `json:"prompt"`
	Response    string    `json:"response"`
	TokensUsed  int       `json:"tokens_used"`
	Cost        float64   `json:"cost"`
	Status      string    `json:"status"` // success, error, pending
	ErrorMsg    string    `json:"error_msg,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
}