import request from '@/utils/request'

/**
 * 查询开课节次安排列表
 * @param {Object} query 查询参数
 */
export function listSchedule(query) {
  return request({
    url: '/education/schedule/list',
    method: 'get',
    params: query
  })
}

/**
 * 查询开课节次安排详细
 * @param {Number} scheduleId 节次安排ID
 */
export function getSchedule(scheduleId) {
  return request({
    url: '/education/schedule/' + scheduleId,
    method: 'get'
  })
}

/**
 * 新增开课节次安排
 * @param {Object} data 节次安排数据
 */
export function addSchedule(data) {
  return request({
    url: '/education/schedule',
    method: 'post',
    data: data
  })
}

/**
 * 修改开课节次安排
 * @param {Object} data 节次安排数据
 */
export function updateSchedule(data) {
  return request({
    url: '/education/schedule',
    method: 'put',
    data: data
  })
}

/**
 * 删除开课节次安排
 * @param {Array} scheduleIds 节次安排ID数组
 */
export function delSchedule(scheduleIds) {
  return request({
    url: '/education/schedule/' + scheduleIds,
    method: 'delete'
  })
}

/**
 * 根据开课ID查询节次安排
 * @param {Number} classId 开课ID
 */
export function getScheduleByClassId(classId) {
  return request({
    url: '/education/schedule/class/' + classId,
    method: 'get'
  })
}

/**
 * 根据开课ID删除节次安排
 * @param {Number} classId 开课ID
 */
export function delScheduleByClassId(classId) {
  return request({
    url: '/education/schedule/class/' + classId,
    method: 'delete'
  })
}

/**
 * 查询指定教室的课程安排
 * @param {Number} classroomId 教室ID
 * @param {Number} semesterId 学期ID
 */
export function getScheduleByClassroom(classroomId, semesterId) {
  return request({
    url: '/education/schedule/classroom/' + classroomId + '/' + semesterId,
    method: 'get'
  })
}

/**
 * 查询指定教师的课程安排
 * @param {Number} teacherId 教师ID
 * @param {Number} semesterId 学期ID
 */
export function getScheduleByTeacher(teacherId, semesterId) {
  return request({
    url: '/education/schedule/teacher/' + teacherId + '/' + semesterId,
    method: 'get'
  })
}

/**
 * 查询指定学期的所有课程安排
 * @param {Number} semesterId 学期ID
 */
export function getScheduleBySemester(semesterId) {
  return request({
    url: '/education/schedule/semester/' + semesterId,
    method: 'get'
  })
}

/**
 * 生成教室课表
 * @param {Number} classroomId 教室ID
 * @param {Number} semesterId 学期ID
 */
export function generateClassroomTimetable(classroomId, semesterId) {
  return request({
    url: '/education/schedule/timetable/classroom/' + classroomId + '/' + semesterId,
    method: 'get'
  })
}

/**
 * 生成教师课表
 * @param {Number} teacherId 教师ID
 * @param {Number} semesterId 学期ID
 */
export function generateTeacherTimetable(teacherId, semesterId) {
  return request({
    url: '/education/schedule/timetable/teacher/' + teacherId + '/' + semesterId,
    method: 'get'
  })
}

/**
 * 批量添加节次安排
 * @param {Number} classId 开课ID
 * @param {Array} scheduleList 节次安排列表
 */
export function batchAddSchedule(classId, scheduleList) {
  return request({
    url: '/education/schedule/batch/' + classId,
    method: 'post',
    data: scheduleList
  })
}

/**
 * 复制节次安排
 * @param {Number} sourceClassId 源开课ID
 * @param {Number} targetClassId 目标开课ID
 */
export function copySchedule(sourceClassId, targetClassId) {
  return request({
    url: '/education/schedule/copy/' + sourceClassId + '/' + targetClassId,
    method: 'post'
  })
}

/**
 * 自动排课
 * @param {Number} classId 开课ID
 * @param {Number} semesterId 学期ID
 * @param {Number} courseHours 课程学时
 */
export function autoSchedule(classId, semesterId, courseHours) {
  return request({
    url: '/education/schedule/auto/' + classId + '/' + semesterId + '/' + courseHours,
    method: 'post'
  })
}

/**
 * 获取时间段统计信息
 * @param {Number} semesterId 学期ID
 */
export function getScheduleStatistics(semesterId) {
  return request({
    url: '/education/schedule/statistics/' + semesterId,
    method: 'get'
  })
}

/**
 * 导出节次安排
 * @param {Object} query 查询参数
 */
export function exportSchedule(query) {
  return request({
    url: '/education/schedule/export',
    method: 'post',
    params: query
  })
}