import { requestClient } from '#/api/request';

enum Api {
  base = '/examPaper/paper',
  list = '/examPaper/paper/list',
}

export interface Paper {
  id: number;
  categoryId: number;
  paparName: string;
  paperDescription: string;
  totalScore: number;
  paperStatus: string;
  questionCount: number;
  bigQuestionNames: string;
  createTime: string;
  updateTime: string;
  delFlag: string;
}

/**
 * 获取试卷列表
 */
async function paperList(params?: any) {
  return requestClient.get<Paper>(Api.list, { params });
}

/**
 * 获取试卷详情
 */
async function paperDetail(id: number) {
  return requestClient.get<Paper>(`${Api.base}/${id}`);
}

/**
 * 新增试卷
 */
function addPaper(paper: Paper) {
  return requestClient.post(Api.base, paper, {
    successMessageMode: 'message',
  });
}
/**
 * 修改试卷
 */
function updatePaper(paper: Paper) {
  return requestClient.put(Api.base, paper, {
    successMessageMode: 'message',
  });
}
// 删除试卷分类
function deletePaper(ids: number[]) {
  return requestClient.delete(`${Api.base}/${ids.join(',')}`, {
    successMessageMode: 'message',
  });
}

export { addPaper, deletePaper, paperDetail, paperList, updatePaper };
