import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getWorkplaceBacklogPage (parameter) {
  return axios({
    url: '/workplace/backlogs/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchWorkplaceBacklogUserById (parameter) {
  return axios({
    url: '/workplace/backlogs/user/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * query list func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function queryWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteWorkplaceBacklogs (parameter) {
  return axios({
    url: '/workplace/backlogs',
    method: 'DELETE',
    data: parameter
  })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs/' + parameter.id,
    method: 'DELETE',
    data: parameter
  })
}

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportWorkplaceBacklog (parameter) {
  return axios({
    url: '/workplace/backlogs/export?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getWorkplaceBacklogUserPage (parameter) {
  return axios({
    url: '/workplace/backlogs/user/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
