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

// 参数接口
export interface AttendanceParams {
  id?: number;
  checkinDate?: string;
  scheduleId?: number;
  month?: number;
  morning?: string;
  afternoon?: string;
  studentName?: string;
  studentNumber?: string;
  createUid?: number;
  createTime?: string;
  modifyTime?: string;
}

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

/**
 * 添加签到记录
 * @param {object} params EasArcTlsAttendance
 * @param {number} params.id
 * @param {object} params.checkinDate 签到日期
 * @param {number} params.scheduleId 排课ID
 * @param {number} params.month 月份
 * @param {string} params.morning a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
 * @param {string} params.afternoon a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
 * @param {string} params.studentName 学员姓名
 * @param {string} params.studentNumber 学生档案号
 * @param {number} params.createUid 创建用户
 * @param {object} params.createTime 创建时间
 * @param {object} params.modifyTime 修改时间
 * @returns
 */
export function addAttendance(params: AttendanceParams): Promise<Service.RequestResult<AttendanceRes[]>> {
  return request.post(`/attendance/add`, params);
}

export function updateAttendance(params: AttendanceParams): Promise<Service.RequestResult<AttendanceRes[]>> {
  return request.put(`/attendance/update`, params);
}

export interface GetAttendanceListParams {
  id?: number;
  studentId?: number;
  month?: number;
  startTime?: string;
  endTime?: string;
  teacherId?: number;
  classId?: number;
}
/**
 * 获取学生列表
 * @param {string} scheduleId
 * @returns
 */
export function getStudentList(params: GetAttendanceListParams) {
  return request.post(`/attendance/getStudentList`, params);
}

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 async function queryAll(): Promise<Service.RequestResult<UserParams[]>> {
  return request.get(`/userinfo/queryAll`);
}
