/**
 * 管理员 - 学员陪练记录API
 */
import request from '@/api/request'

/**
 * 学员陪练记录查询参数
 */
export interface StudentPracticeParams {
  page: number
  size: number
  student_name?: string
  position?: string
  scene_type?: string
  result?: string  // excellent/good/average/needs_improvement
  start_date?: string
  end_date?: string
}

/**
 * 学员陪练记录
 */
export interface StudentPracticeRecord {
  id: number
  student_id: number
  student_name: string
  position: string | null
  session_id: string
  scene_name: string
  scene_type: string
  duration_seconds: number
  round_count: number
  score: number | null
  result: string
  practice_time: string | null
}

/**
 * 陪练统计数据
 */
export interface PracticeStatistics {
  total_count: number
  avg_score: number
  total_duration_hours: number
  excellent_rate: number
}

/**
 * 获取学员陪练记录列表
 */
export function getStudentPracticeRecords(params: StudentPracticeParams) {
  return request.get<{
    items: StudentPracticeRecord[]
    total: number
    page: number
    page_size: number
    pages: number
  }>('/api/v1/manager/student-practice', params)
}

/**
 * 获取学员陪练统计
 */
export function getStudentPracticeStatistics() {
  return request.get<PracticeStatistics>('/api/v1/manager/student-practice/statistics')
}

/**
 * 获取指定会话的对话记录
 */
export function getSessionConversation(sessionId: string) {
  return request.get<{
    session_id: string
    conversation: Array<{
      role: string
      content: string
      timestamp: string
      sequence: number
    }>
    total_count: number
  }>(`/api/v1/manager/student-practice/${sessionId}/conversation`)
}

