import request from '@/utils/request';

/**
 * 获取后台用户列表
 * @param {object} params
 * @returns {array} data
 */
export const getAccountList = (params) => {
  return request.request({
    url: '/user/get',
    method: 'get',
    params,
  });
};

/**
 * 添加后台用户
 * @param {object} data
 *  name  账号名称
 *  password  密码
 *  role  权限角色
 * @returns {array} data
 */
export const addUser = (data) => {
  return request.request({
    url: '/user/create',
    method: 'post',
    data,
  });
};

/**
 * 修改后台用户
 * @param {object} data
 *  name  账号名称
 *  password  密码
 *  role  权限角色
 * @returns {array} data
 */
export const updateUser = (data) => {
  return request.request({
    url: '/user/update',
    method: 'post',
    data,
  });
};

/**
 * 修改后台用户状态
 * @param {object} data
 *  name  账号名称
 *  status  用户状态
 * @returns {array} data
 */
export const changeUserStatus = (data) => {
  return request.request({
    url: '/user/status',
    method: 'post',
    data,
  });
};

/**
 * 删除后台用户
 * @param {object} data
 *  name 用户名
 * @returns {array} data
 */
export const deleteUser = (data) => {
  return request.request({
    url: '/user/delete',
    method: 'post',
    data,
  });
};
