import request from '@/utils/request'

// 创建须知
export function createNeedKnow(data) {
  return request({
    url: '/system/need-know/create',
    method: 'post',
    data: data
  })
}

// 更新须知
export function updateNeedKnow(data) {
  return request({
    url: '/system/need-know/update',
    method: 'put',
    data: data
  })
}

// 删除须知
export function deleteNeedKnow(id) {
  return request({
    url: '/system/need-know/delete?id=' + id,
    method: 'delete'
  })
}

// 发布须知版本
export function releaseNeedKnow(data) {
  return request({
    url: '/system/need-know/release?id=',
    method: 'post',
    data: data
  })
}

// 获得须知
export function getNeedKnow(id) {
  return request({
    url: '/system/need-know/get?id=' + id,
    method: 'get'
  })
}

// 根据key获得须知
export function getNeedKnowByKey(key) {
  return request({
    url: '/system/need-know/getByKey?key=' + key,
    method: 'get'
  })
}

// 获得须知分页
export function getNeedKnowPage(query) {
  return request({
    url: '/system/need-know/page',
    method: 'get',
    params: query
  })
}

export function getNeedKnowVersionList(id) {
  return request({
    url: '/system/need-know/version/list?id=' + id,
    method: 'get',
  })
}

// 导出须知 Excel
export function exportNeedKnowExcel(query) {
  return request({
    url: '/system/need-know/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 下载需知
export function download(query) {
  return request({
    url: '/system/need-know/download',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
