import request from '@/axios';

export const getList = (current, size, params, deptId) => {
  return request({
    url: '/blade-system/user/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      deptId,
    },
  });
};

export const remove = ids => {
  return request({
    url: '/blade-system/user/remove',
    method: 'post',
    params: {
      ids,
    },
  });
};

export const add = row => {
  return request({
    url: '/blade-system/user/submit',
    method: 'post',
    data: row,
  });
};

export const update = row => {
  return request({
    url: '/blade-system/user/update',
    method: 'post',
    data: row,
  });
};

export const updatePlatform = (userId, userType, userExt) => {
  return request({
    url: '/blade-system/user/update-platform',
    method: 'post',
    params: {
      userId,
      userType,
      userExt,
    },
  });
};

export const getUser = id => {
  return request({
    url: '/blade-system/user/detail',
    method: 'get',
    params: {
      id,
    },
  });
};

export const getCustomerOptions = () => {
  return request({
    url: '/blade-system/user/customer-options',
    method: 'get',
  });
};

export const getUserPlatform = id => {
  return request({
    url: '/blade-system/user/platform-detail',
    method: 'get',
    params: {
      id,
    },
  });
};

export const getUserInfo = () => {
  return request({
    url: '/blade-system/user/info',
    method: 'get',
  });
};

export const resetPassword = userIds => {
  return request({
    url: '/blade-system/user/reset-password',
    method: 'post',
    params: {
      userIds,
    },
  });
};

export const setPassword = (userId, password, password2) => {
  return request({
    url: '/blade-system/user/set-password',
    method: 'post',
    params: {
      userId,
      password,
      password2,
    },
  });
};

export const updatePassword = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: '/blade-system/user/update-password',
    method: 'post',
    params: {
      oldPassword,
      newPassword,
      newPassword1,
    },
  });
};

export const updateInfo = row => {
  return request({
    url: '/blade-system/user/update-info',
    method: 'post',
    data: row,
  });
};

export const grant = (userIds, roleIds) => {
  return request({
    url: '/blade-system/user/grant',
    method: 'post',
    params: {
      userIds,
      roleIds,
    },
  });
};

export const auditPass = userIds => {
  return request({
    url: '/blade-system/user/audit-pass',
    method: 'post',
    params: {
      userIds,
    },
  });
};

export const auditRefuse = userIds => {
  return request({
    url: '/blade-system/user/audit-refuse',
    method: 'post',
    params: {
      userIds,
    },
  });
};

export const setLeader = userId => {
  return request({
    url: '/blade-system/user/set-leader',
    method: 'post',
    params: {
      userId,
    },
  });
};

export const getLeaderList = (tenantId, realName) => {
  return request({
    url: '/blade-system/user/leader-list',
    method: 'get',
    params: {
      tenantId,
      realName,
    },
  });
};

export const getUserPage = (current, size, account, name) => {
  return request({
    url: '/blade-system/user/user-page',
    method: 'get',
    params: {
      current,
      size,
      account,
      name,
    },
  });
};
