import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ExamQuery, ExamVO, ExamForm, ExamScoreVO } from './types';

// 查询考试列表
export function listExam(query: ExamQuery): AxiosPromise<ExamVO[]> {
  return request({ url: '/edu/exam/list', method: 'get', params: query });
}

// 查询考试详情
export function getExam(id: number | string): AxiosPromise<ExamVO> {
  return request({ url: '/edu/exam/' + id, method: 'get' });
}

// 查询考试成绩明细
export function getExamScores(examId: number | string): AxiosPromise<ExamScoreVO[]> {
  return request({ url: '/edu/exam/scores/' + examId, method: 'get' });
}

// 新增考试
export function addExam(data: ExamForm) {
  return request({ url: '/edu/exam', method: 'post', data });
}

// 修改考试
export function updateExam(data: ExamForm) {
  return request({ url: '/edu/exam', method: 'put', data });
}

// 删除考试
export function delExam(ids: string | number | (string | number)[]) {
  return request({ url: '/edu/exam/' + ids, method: 'delete' });
}
