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

/**
 * 更新用户权限
 * @return {Promise} api
 */
export function reloadCache() {
  return api.get('User.User/reloadCache', {
    isTransformResponse: true
  });
}
/**
 * 获取用户菜单
 * @return {Promise} api
 */
export function getUserMenu() {
  return api.get('User.User/getUserMenu', {
    isTransformResponse: true
  });
}
/**
 * 获取用户部门树
 * @return {Promise} api
 */
export function getUserDepartmentTree() {
  return api.get('User.User/getUserDepartmentTree', {
    isTransformResponse: true
  });
}

/**
 * 账号密码登录
 * @return {Promise} api
 */
export function getUserInfo() {
  return api.post(
    'User.User/getUserInfo',
    {},
    {
      isTransformResponse: true,
      isShowErrorMessage: true
    }
  );
}
/**
 * 获取用户列表
 * @param {Object} data
 * @return {Promise} api
 */
export function getUserList(data) {
  return api.post('User.User/getUserList', data);
}
/**
 * 重置用户密码
 * @param {Object} data
 * @return {Promise} api
 */
export function resetUserPassword(data) {
  return api.post('User.User/resetUserPassword', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '重置失败'
  });
}
/**
 * 重置用户密码
 * @param {Object} data
 * @return {Promise} api
 */
export function deleteUser(data) {
  return api.post('User.User/deleteUser', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '删除失败'
  });
}
/**
 * 更新用户状态
 * @param {Object} data
 * @return {Promise} api
 */
export function updateUserStatus(data) {
  return api.post('User.User/updateUserStatus', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '更新失败'
  });
}
/**
 * 添加用户
 * @param {Object} data
 * @return {Promise} api
 */
export function addUser(data) {
  return api.post('User.User/addUser', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '添加失败'
  });
}
/**
 * 编辑用户
 * @param {Object} data
 * @return {Promise} api
 */
export function editUser(data) {
  return api.post('User.User/editUser', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '编辑失败'
  });
}


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

/**
 * 导入用户
 * @param {Object} data
 * @return {Promise} api
 */
export const importExcel = createApiUrl('User.User/importExcel');

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


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