import request from '@/utils/request'

/**
 * 查询学期信息列表
 * @param {Object} query 查询参数
 */
export function listSemester(query) {
  return request({
    url: '/education/semester/list',
    method: 'get',
    params: query
  })
}

/**
 * 查询学期信息详细
 * @param {Number} semesterId 学期ID
 */
export function getSemester(semesterId) {
  return request({
    url: '/education/semester/' + semesterId,
    method: 'get'
  })
}

/**
 * 新增学期信息
 * @param {Object} data 学期数据
 */
export function addSemester(data) {
  return request({
    url: '/education/semester',
    method: 'post',
    data: data
  })
}

/**
 * 修改学期信息
 * @param {Object} data 学期数据
 */
export function updateSemester(data) {
  return request({
    url: '/education/semester',
    method: 'put',
    data: data
  })
}

/**
 * 删除学期信息
 * @param {Array} semesterIds 学期ID数组
 */
export function delSemester(semesterIds) {
  return request({
    url: '/education/semester/' + semesterIds,
    method: 'delete'
  })
}

/**
 * 发布学期
 * @param {Number} semesterId 学期ID
 */
export function publishSemester(semesterId) {
  return request({
    url: '/education/semester/publish/' + semesterId,
    method: 'put'
  })
}

/**
 * 归档学期
 * @param {Number} semesterId 学期ID
 */
export function archiveSemester(semesterId) {
  return request({
    url: '/education/semester/archive/' + semesterId,
    method: 'put'
  })
}

/**
 * 获取当前学期
 */
export function getCurrentSemester() {
  return request({
    url: '/education/semester/current',
    method: 'get'
  })
}

/**
 * 获取可选课学期列表
 */
export function getEnrollableSemesters() {
  return request({
    url: '/education/semester/enrollable',
    method: 'get'
  })
}

/**
 * 导出学期信息
 * @param {Object} query 查询参数
 */
export function exportSemester(query) {
  return request({
    url: '/education/semester/export',
    method: 'post',
    params: query
  })
}