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

export interface QueryScheduleParams {
  studentId?: number | null | undefined;
  classId?: number | null | undefined;
  subjectId?: number | null | undefined;
  teacherId?: number | null | undefined;
  startTime?: string | null | undefined;
  endTime?: string | null | undefined;
  week?: number | null | undefined;
  roomId?: number | null | undefined;
  assistantId?: number | null | undefined;
  categoryId?: number | null | undefined;
}

interface ScheduleResponse {
  id?: number;
  week?: number;
  startTime?: string;
  endTime?: string;
  roomId?: number;
  classroom?: string;
  classId?: number;
  assistantId?: number;
  assistantName?: string;
  teacherId?: number;
  teacherName?: string;
  categoryId?: number;
  category?: string;
  subjectsId?: number;
  subjects?: string;
  createTime?: string;
  modifyTime?: string;
  createUid?: number;
  disabled?: string;
}

export function querySchedule(params: QueryScheduleParams): Promise<Service.RequestResult<ScheduleResponse[]>> {
  return request.post(`/schedule/querySchedule`, params);
}

export interface EasSysStudentOptional {
  id?: number;
  studentNumber?: string;
  studentName?: string;
  gender?: string;
  phone?: string;
  email?: string;
  enrollmentDate?: Date;
  passwd?: string;
  avatar?: string;
  createTime?: Date;
  modifyTime?: Date;
  admissionsId?: number;
  managerId?: number;
  createUid?: number;
  disabled?: string;
}

export function getStudentByKeyword(keyword: string): Promise<Service.RequestResult<EasSysStudentOptional[]>> {
  return request.get(`/student/getStudentByKeyword?keyword=${keyword}`);
}

export interface UserParams {
  id?: number;
  username?: string;
  passwd?: string;
  email?: string;
  relname?: string;
  phone?: string;
  address?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  disabled?: string;
}
export function queryUserAll(): Promise<Service.RequestResult<UserParams[]>> {
  return request.get(`/userinfo/queryAll`);
}

export interface ClassRoomParams {
  id?: number;
  name?: string;
  managerId?: number;
  address?: string;
  manager?: string;
  floor?: number;
  capacity?: number;
  comment?: string;
  disabled?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
}

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

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

/**
 * 根据条件进行查询课程类别
 * @param {string} pageNum
 * @param {string} pageSize
 * @param {object} params EasEduCategory
 * @param {number} params.id
 * @param {string} params.name 学科名称
 * @param {string} params.description 学科描述
 * @param {object} params.createTime 创建时间
 * @param {object} params.modifyTime 修改时间
 * @param {number} params.createUid 创建用户ID
 * @param {string} params.disabled 状态
 * @returns
 */
export function queryCategoryParams(
  pageNum: number,
  pageSize: number,
  params: CategoryParams
): Promise<Service.RequestResult<CategoryParams[]>> {
  return request.post(`/category/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

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

/**
 * 查询所有的班级类
 * @returns
 */
export function queryClassAll(): Promise<Service.RequestResult<ClassParams[]>> {
  return request.get(`/class/selectTotal`);
}
