import axios from 'axios';
import {
  MarkQualityMonitorListFilter,
  MarkQualityMonitorListPageParam,
  MarkQualityMonitorListPageRes,
  QMScoreItem,
  QMScoreListParam,
  MarkArbitrationListPageRes,
  MarkArbitrationListPageParam,
  MarkTaskListPageRes,
  MarkTaskListPageParam,
  MarkTrialListPageRes,
  MarkTrialListPageParam,
  MarkMarkerListPageParam,
  MarkMarkerListPageRes,
  MarkGroupListPageParam,
  MarkGroupListPageRes,
  MarkGroupUpdateParams,
  MarkStatInfo,
  MarkStatListPageParam,
  MarkStatListPageRes,
  MarkRejectTaskParam,
} from './types/mark';

// 质量监控
// 获取质量监控列表
export function getQualityMonitorList(
  params: MarkQualityMonitorListPageParam
): Promise<MarkQualityMonitorListPageRes> {
  return axios.post('/api/mark/quality/monitor/list', {}, { params });
}
// 重新计算
export function qualityMonitorCalculate(
  params: MarkQualityMonitorListFilter
): Promise<boolean> {
  return axios.post('/api/mark/re-calculate', {}, { params });
}
// 给分曲线
export function qualityMonitorScoreList(
  params: QMScoreListParam
): Promise<QMScoreItem[]> {
  return axios.post('/api/mark/re-calculate', {}, { params });
}

// 仲裁管理
// 获取仲裁列表
export function getArbitrationList(
  params: MarkArbitrationListPageParam
): Promise<MarkArbitrationListPageRes> {
  return axios.post('/api/mark/arbitration/list', {}, { params });
}

// 任务管理
// 获取任务列表
export function getMarkTaskList(
  params: MarkTaskListPageParam
): Promise<MarkTaskListPageRes> {
  return axios.post('/api/mark/task/list', {}, { params });
}

// 任务打回
export function markTaskReject(params: MarkRejectTaskParam): Promise<boolean> {
  return axios.post('/api/mark/task/reject', {}, { params });
}

// 试评管理
// 获取试评列表
export function getMarkTrialList(
  params: MarkTrialListPageParam
): Promise<MarkTrialListPageRes> {
  return axios.post('/api/mark/task/list', {}, { params });
}

// 评卷员管理
// 获取评卷员列表
export function getMarkMarkerList(
  params: MarkMarkerListPageParam
): Promise<MarkMarkerListPageRes> {
  return axios.post('/api/mark/marker/list', {}, { params });
}

// 启用、禁用评卷员
export function markMarkerEnable({
  ids,
  enable,
}: {
  ids: number[];
  enable: boolean;
}): Promise<boolean> {
  return axios.post('/api/mark/marker/enable', {}, { params: { ids, enable } });
}
// 解绑评卷员
export function markMarkerUnbind(id: number) {
  return axios.post('/api/mark/marker/unbind', {}, { params: { id } });
}

// 回收任务
export function markMarkerTaskRecycle(ids: number[]) {
  return axios.post('/api/mark/task/recycle', {}, { params: { ids } });
}

// 设置评卷数量
export function markMarkerSetTaskCount({
  ids,
  count,
}: {
  ids: number[];
  count: number;
}) {
  return axios.post('/api/mark/task/set-count', {}, { params: { ids, count } });
}

// 重置密码
export function markMarkerResetPassword(ids: number[]) {
  return axios.post('/api/mark/task/reset-password', {}, { params: { ids } });
}
// 重置已评数量
export function markMarkerResetFinishCount(id: number) {
  return axios.post(
    '/api/mark/task/reset-finish-count',
    {},
    { params: { id } }
  );
}

// 分组管理
// 获取分组列表
export function getMarkGroupList(
  params: MarkGroupListPageParam
): Promise<MarkGroupListPageRes> {
  return axios.post('/api/mark/group/list', {}, { params });
}
// 结束分组
export function markGroupEnd(id: number): Promise<boolean> {
  return axios.post('/api/mark/group/end', {}, { params: { id } });
}

// 获取分组信息
export function getMarkGroupInfo(id: number): Promise<MarkGroupUpdateParams> {
  return axios.post('/api/mark/group/info', {}, { params: { id } });
}

// 修改分组
export function markGroupUpdate(
  params: MarkGroupUpdateParams
): Promise<boolean> {
  return axios.post('/api/mark/group/update', params);
}

// 设置试评数量
export function markGroupSetTrialCount({
  subjectId,
  count,
}: {
  subjectId: number;
  count: number;
}): Promise<boolean> {
  return axios.post(
    '/api/mark/group/set-trial-count',
    {},
    { params: { subjectId, count } }
  );
}

// 数据校对
export function markGroupDataCheck(subjectId: number) {
  return axios.post(
    '/api/mark/group/data-check',
    {},
    { params: { subjectId } }
  );
}

// 关闭分组
export function markGroupClose(ids: number) {
  return axios.post('/api/mark/group/close', {}, { params: { ids } });
}

// 评卷进度统计
// 获取评卷进度统计信息
export function getMarkStatInfo(examId: number): Promise<MarkStatInfo> {
  return axios.post('/api/mark/stat/info', {}, { params: { examId } });
}

// 获取评卷进度统计列表
export function getMarkStatList(
  params: MarkStatListPageParam
): Promise<MarkStatListPageRes> {
  return axios.post('/api/mark/stat/list', {}, { params });
}

// 关闭科目
export function markSubjectClose(subjectIds: number[]): Promise<boolean> {
  return axios.post('/api/mark/subject/close', {}, { params: { subjectIds } });
}
