import { request } from '@/service/request';

// 参数接口
export interface QueryParams {
  id?: number;
  name?: string;
  description?: string;
  categoryId?: number;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  disabled?: string;
}

// 响应接口
export interface Res {
  status: boolean;
  msg: string;
  data: Record<string, unknown>;
  total: number;
}

export function search(
  pageNum: number,
  pageSize: number,
  params: QueryParams
): Promise<Service.RequestResult<QueryParams[]>> {
  return request.post(`/subject/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

export function add(params: QueryParams): Promise<Service.RequestResult<Res>> {
  return request.post(`/subject/add`, params);
}

export function edit(params: QueryParams): Promise<Service.RequestResult<Res>> {
  return request.post(`/subject/update`, params);
}

export function del(id: number): Promise<Service.RequestResult<Res>> {
  return request.delete(`/subject/delete/${id}`);
}

export interface CateGoryParams {
  id?: number;
  name?: string;
  description?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  disabled?: string;
}

export function queryCateGory(
  pageNum: number,
  pageSize: number,
  params: CateGoryParams
): Promise<Service.RequestResult<CateGoryParams[]>> {
  return request.post(`/category/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

// 参数接口
export interface ScoreParams {
  id?: number;
  studentNumber?: string;
  categoryId?: number;
  subjectId?: number;
  testDate?: Record<string, unknown>;
  score?: number;
  passRate?: number;
  excelRate?: number;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  comment?: string;
}

export function queryScore(
  pageNum: number,
  pageSize: number,
  params: ScoreParams
): Promise<Service.RequestResult<ScoreParams[]>> {
  return request.post(`/scores/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

export interface StudentParams {
  id?: number;
  archiveNumber?: string;
  studentNumber?: string;
  studentName?: string;
  gender?: string;
  birthdate?: Record<string, unknown>;
  address?: string;
  phone?: string;
  email?: string;
  enrollmentDate?: Record<string, unknown>;
  graduationDate?: Record<string, unknown>;
  grade?: number;
  major?: string;
  minor?: string;
  university?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  admissionsId?: number;
  managerId?: number;
  createUid?: number;
  studentIdnumber?: string;
}

export function studentRequest(
  pageNum: number,
  pageSize: number,
  params: StudentParams
): Promise<Service.RequestResult<StudentParams[]>> {
  return request.post(`/student/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

// 参数接口
export interface QueryStudentScoresParams {
  groupId?: number;
  studentId?: number;
  subjectId?: number;
  categoryId?: number;
  studentName?: string;
  score?: Record<string, unknown>;
}

export interface ScoresPojo {
  id: number;
  groupId: number;
  categoryId: number;
  subjectId: number;
  testDate: Date;
  type: string;
  studentId: number;
  groupName: string;
  studentName: string;
  score: number;
  passRate: number;
  excelRate: number;
  comment: string;
  categoryName: string;
  subjectsName: string;
}

export function queryStudentScores(
  pageNum: number,
  pageSize: number,
  params: QueryStudentScoresParams
): Promise<Service.RequestResult<ScoresPojo[]>> {
  return request.post(`/scores/queryScores?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

// 参数接口
export interface AddScoreParams {
  id?: number;
  studentNumber?: string;
  categoryId?: number;
  subjectId?: number;
  testDate?: Record<string, unknown>;
  score?: number;
  passRate?: number;
  excelRate?: number;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  comment?: string;
}

/**
 * 添加学生成绩信息
 * @param {object} params EasArcTlsScores
 * @param {number} params.id ID
 * @param {string} params.studentNumber 学员档案
 * @param {number} params.categoryId 类目ID
 * @param {number} params.subjectId 科目ID
 * @param {object} params.testDate 考试时间
 * @param {number} params.score 分数
 * @param {number} params.passRate 通过率
 * @param {number} params.excelRate 及格率
 * @param {object} params.createTime 创建时间
 * @param {object} params.modifyTime 修改时间
 * @param {number} params.createUid 创建用户ID
 * @param {string} params.comment 考试备注信息  如 第二次考试  第三次考试
 * @returns
 */
export function addStudentScore(params: AddScoreParams): Promise<Service.RequestResult<Res>> {
  return request.post(`/scores/add`, params);
}
