import httpRequest from '@/utils/axios'

// 获取事务类型列表
export function getAffairType(params) {
  return httpRequest({
    url: '/v2/lobby/affairs',
    method: 'get',
    params
  })
}
// 获取事务列表
export function getAffairList(params) {
  return httpRequest({
    url: '/v2/lobby/processes',
    method: 'get',
    params
  })
}
// 获取事务详情
export function getAffair(id) {
  return httpRequest({
    url: `/v2/lobby/processes/${id}`,
    method: 'get'
  })
}
// 创建事务
export function createAffair(data) {
  return httpRequest({
    url: '/v2/lobby/processes',
    method: 'post',
    data
  })
}
// 更新事务
export function updateAffair(id, data) {
  return httpRequest({
    url: `/v2/lobby/processes/${id}`,
    method: 'post',
    data
  })
}
// 删除事务
export function deleteAffair(id) {
  return httpRequest({
    url: `/v2/lobby/processes/${id}`,
    method: 'delete'
  })
}
// 上传文件
export function upload(data) {
  return httpRequest({
    url: '/v2/lobby/tools/upload',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
// 获取学期
export function getSemesters(params) {
  return httpRequest({
    url: '/v2/lobby/semesters',
    method: 'get',
    params
  })
}
// 获取课程
export function getCourses(data) {
  return httpRequest({
    url: `/v2/lobby/semesters/${data.id}/courses`,
    method: 'get'
  })
}
