import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ScheduleForm, ScheduleQuery, ScheduleVO, CheckInForm } from './types';

// 查询排课列表
export function listSchedule(query: ScheduleQuery): AxiosPromise<ScheduleVO[]> {
  return request({
    url: '/edu/schedule/list',
    method: 'get',
    params: query
  });
}

// 查询排课详细(含学生关联)
export function getSchedule(id: number | string): AxiosPromise<ScheduleVO> {
  return request({
    url: '/edu/schedule/' + id,
    method: 'get'
  });
}

// 新增排课
export function addSchedule(data: ScheduleForm) {
  return request({
    url: '/edu/schedule',
    method: 'post',
    data: data
  });
}

// 修改排课
export function updateSchedule(data: ScheduleForm) {
  return request({
    url: '/edu/schedule',
    method: 'put',
    data: data
  });
}

// 删除排课
export function delSchedule(id: string | number | (string | number)[]) {
  return request({
    url: '/edu/schedule/' + id,
    method: 'delete'
  });
}

// 学生签到
export function checkInSchedule(data: CheckInForm) {
  return request({
    url: '/edu/schedule/checkIn',
    method: 'put',
    data: data
  });
}

// 课后消课(扣合同课时)
export function consumeSchedule(scheduleId: number | string) {
  return request({
    url: '/edu/schedule/consume/' + scheduleId,
    method: 'put'
  });
}

// 学生请假
export function leaveSchedule(data: CheckInForm) {
  return request({
    url: '/edu/schedule/leave',
    method: 'put',
    data: data
  });
}
