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

interface EasStudentQuery {
  avatar?: string;
  enrollmentDate?: Date | null;
  gender?: string | null;
  managerId?: number | null;
  phone?: string | null;
  studentName?: string | null;
  studentId?: number | null;
  admissionsId?: number | null;
  type?: string | null;
  admissionsName?: string | null;
  managerName?: string | null;
  groupId?: number | null;
}

interface GroupStudentsPojo {
  studentId: number;
  studentName: string;
  avatar: string;
  studentNumber: string;
  managerName: string;
  phone: string;
  email: string;
  gender: string;
  enrollmentDate: string;
  morning?: string;
  afternoon?: string;
  checkinDate: Date;
  admissionsName: string;
  scheduleId?: number;
  category?: string;
  subject?: string;
  teacher?: string;
  teacherPhone?: string;
  groupId?: string;
  groupName?: string;
}

export interface SubmitGroupStudentFormRes {
  status: boolean;
  msg: string;
  data: Record<string, unknown>;
  code: number;
}

export function queryClassStudent(params: EasStudentQuery): Promise<Service.RequestResult<GroupStudentsPojo>> {
  return request.post(`/class/groupStudent`, params);
}

export function submitGroupStudentDelete(rowId: number): Promise<Service.RequestResult<SubmitGroupStudentFormRes>> {
  return request.delete(`/class/groupStudent/${rowId}`);
}

interface EasEduCltRelation {
  id?: number;
  classId?: number;
  studentId?: number;
  createTime?: Date;
  modifyTime?: Date;
  createUid?: number;
  type?: string;
}

/**
 * 更新班级学员
 * @param {string} groupId
 * @param {array} params integer
 * @returns
 */
export function submitGroupStudentUpdate(
  params: EasEduCltRelation
): Promise<Service.RequestResult<SubmitGroupStudentFormRes>> {
  return request.put(`/class/groupStudent`, params);
}
