liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { ExamPaperView, ExamScoreDetail, ExamScoreDetailRow, ExamScorePageQuery, ExamScoreSummaryItem } from '#/views/x/tms/examScore/types';
 
import { defHttp } from '#/api/request';
 
const prefix = '/api/tms/exam-score';
 
async function unwrapData<T>(promise: Promise<any>): Promise<T> {
  const res = await promise;
  if (res && typeof res === 'object' && 'data' in res && ('code' in res || 'msg' in res)) {
    return res.data as T;
  }
  return res as T;
}
 
export function getExamScoreList(params: ExamScorePageQuery) {
  return unwrapData<{ list: ExamScoreSummaryItem[]; pagination: Record<string, any> }>(
    defHttp.get({ url: `${prefix}/list`, params }),
  );
}
 
export function getExamScoreDetail(id: string) {
  return unwrapData<ExamScoreDetail>(defHttp.get({ url: `${prefix}/${id}` }));
}
 
export function getExamPaperView(examId: string) {
  return unwrapData<ExamPaperView>(defHttp.get({ url: `${prefix}/paper/${examId}` }));
}
 
export function exportExamScores(ids: string[]) {
  return unwrapData<ExamScoreDetailRow[]>(defHttp.post({ url: `${prefix}/export`, data: { ids } }));
}