import {
  api,
  downloadFile,
  createApiUrl
} from '~/utils/axios';


/**
 * 导出新闻
 * @param {Object} data
 * @return {Promise} api
 */
export function exportExcel(data) {
  downloadFile(createApiUrl('News.News/exportExcel'), data);
}

/**
 * 下载新闻模板
 * @param {Object} data
 * @return {Promise} api
 */
export function downloadTemplate(data) {
  downloadFile(createApiUrl('News.News/downloadTemplate'), data);
}

/**
 * 导入新闻
 * @param {Object} data
 * @return {Promise} api
 */
export const importExcel = createApiUrl('News.News/importExcel');







/**
 * 获取字典值
 * @param {Object} data
 * @return {Promise} api
 */
export function getDictionary(data) {
  return api.post('Dictionary.Dictionary/getDictionary', data, {});
}


/**
 * 获取新闻列表
 * @param {Object} data
 * @return {Promise} api
 */
export function getNewsList(data) {
  return api.post('News.News/getNewsList', data);
}

/**
 * 删除新闻
 * @param {Object} data
 * @return {Promise} api
 */
export function deleteNews(data) {
  return api.post('News.News/deleteNews', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '删除失败'
  });
}

/**
 * 添加新闻
 * @param {Object} data
 * @return {Promise} api
 */
export function addNews(data) {
  return api.post('News.News/addNews', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '添加失败'
  });
}
/**
 * 编辑新闻
 * @param {Object} data
 * @return {Promise} api
 */
export function editNews(data) {
  return api.post('News.News/editNews', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '编辑失败'
  });
}