import { User, fileDownload, files, todoApi } from '@/api'
import request from '@/utils/require'

export function getKdListTreeNew() {
  return request({
    url: `${User}/org/getTreeDataOrganKudianGouXiao`,
    method: 'get',
  })
}

/* 获取列表数据 */
export function getListData(data, page) {
  return request({
    url: `${todoApi}/notice/pageList/${page.page}/${page.size}`,
    method: 'post',
    data: data
  })
}
//查询详情
export function detailInfo(id) {
  return request({
    url: `${todoApi}/notice/showNotice?id=${id}`,
    method: 'post',
  })
}
//新增
export function saveData(data) {
  return request({
    url: `${todoApi}/notice/addNotice`,
    method: 'post',
    data: data
  })
}
//修改
export function updateData(data) {
  return request({
    url: `${todoApi}/notice/updateNotice`,
    method: 'post',
    data: data
  })
}

//删除
export function deleteData(id) {
  return request({
    url: `${todoApi}/notice/deleteNotice?id=${id}`,
    method: 'post',
  })
}

export function viewFile(fileId) {
  return request({
    url: `${fileDownload}?id=${fileId}`,
    method: 'GET',
    responseType: 'arraybuffer'
  })
}

export function viewFileData(fileId) {
  return request({
    url: `${files}/file/findById?id=${fileId}`,
    method: 'post',
  })
}

export function viewAllFileData(fileId) {
  return request({
    url: `${files}/file/findByAll/${fileId}`,
    method: 'get',
  })
}

//
export function listDevAndRef() {
  return request({
    url: `${User}/org/listDevAndRef`,
    method: 'get',
  })
}

//获取通知对象列表
export function listGroupOrg() {
  return request({
    url: `${User}/org/listGroupOrg`,
    method: 'get',
  })
}
//查询详情
export function revocation(data) {
  return request({
    url: `${todoApi}/notice/revocation`,
    method: 'put',
    data
  })
}
