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);
}
