import { http } from '@/http/http'

enum Api {
  base = '/exam/exam',
  list = '/exam/exam/list',
}

export interface Exam {
  id: number
  categoryId: number
  categoryName: string
  examName: string
  paperId: number
  examStartTime: string
  examEndTime: string
  examDuration: number
  passScore: number
  isLimit: number
  isSubjective: number
  examStatus: string
  createTime: string
  updateTime: string
  delFlag: string
}

/**
 * 获取试卷列表
 */
async function examList(params?: any) {
  return http.get<Exam>(Api.list, params)
}

/**
 * 获取试卷详情
 */
async function examDetail(id: number) {
  return http.get<Exam>(`${Api.base}/${id}`)
}

// 我的待考试卷列表
async function myPendingExamList(params?: any) {
  return http.get<Exam>(`${Api.base}/my-start-list`, params)
}

// 我的已考试卷列表
async function myEndExamList(params?: any) {
  return http.get<Exam>(`${Api.base}/my-end-list`, params)
}

// 考试试卷详情
async function examPaperDetail(id: number) {
  return http.get<Exam>(`${Api.base}/paper/${id}`)
}

// 人工阅卷
async function startExamList(params?: any) {
  return http.get<Exam>(`${Api.base}/start-list`, params)
}

export {
  examDetail,
  examList,
  examPaperDetail,
  myEndExamList,
  myPendingExamList,
  startExamList,
}
