import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EvaluationApplyRow, EvaluationParticipantStats, EvaluationSyncEmployeeOption, EvaluationSyncRequest, MainExamEvaluationQuery, MainExamEvaluationVO } from './types';

export function listEvaluation(query: MainExamEvaluationQuery): AxiosPromise<MainExamEvaluationVO[]> {
  return request({
    url: '/main/examEvaluation/list',
    method: 'get',
    params: query
  });
}

export function getEvaluation(id: string | number): AxiosPromise<MainExamEvaluationVO> {
  return request({
    url: '/main/examEvaluation/' + id,
    method: 'get'
  });
}

export function updateEvaluationStatus(id: string | number, status: string) {
  return request({
    url: `/main/examEvaluation/status/${id}/${status}`,
    method: 'put'
  });
}

export function getEvaluationParticipantStats(ids: Array<string | number>): AxiosPromise<EvaluationParticipantStats> {
  return request({
    url: '/main/examEvaluation/stats/participant',
    method: 'get',
    params: { ids: ids.join(',') }
  });
}

export function getEvaluationSyncEmployeeOptions(): AxiosPromise<EvaluationSyncEmployeeOption[]> {
  return request({
    url: '/main/examEvaluation/sync/employeeOptions',
    method: 'get'
  });
}

export function syncEvaluationToEmployees(data: EvaluationSyncRequest) {
  return request({
    url: '/main/examEvaluation/sync/employees',
    method: 'post',
    data
  });
}

export function listEvaluationApply(query: { evaluationId: string | number; keyword?: string; pageNum: number; pageSize: number }): AxiosPromise<EvaluationApplyRow[]> {
  return request({
    url: '/main/examEvaluation/applyList',
    method: 'get',
    params: query
  });
}

export function removeEvaluationApply(applyId: string | number) {
  return request({
    url: `/main/examEvaluation/apply/${applyId}`,
    method: 'delete'
  });
}

export function getExamScoreList(data: { examInfoId: string | number; page?: number }) {
  return request({
    url: '/main/examEvaluation/score-list',
    method: 'post',
    data
  });
}

export function getExamPaperQuestions(data: { examInfoId: string | number }) {
  return request({
    url: '/main/examEvaluation/paper-questions',
    method: 'post',
    data
  });
}

export function getExamAnswerList(data: { examInfoId: string | number }) {
  return request({
    url: '/main/examEvaluation/answer-list',
    method: 'post',
    data
  });
}
