import request from '@/router/axios';

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

export const getAllList =
  (current, size, params, tenantId) => {
    return request({
      url: '/api/jobslink-api/system/tuser/list',
      method: 'get',
      params: {
        ...params,
        current,
        size,
        tenantId,
      }
    })
  }

export const remove =
  (ids) => {
    return request({
      url: '/api/jobslink-api/system/tuser/remove',
      method: 'post',
      params: {
        ids,
      }
    })
  }

export const add =
  (row) => {
    return request(
      {url: '/api/jobslink-api/system/tuser/submit', method: 'post', data: row})
  }

export const update =
  (row) => {
    return request(
      {url: '/api/jobslink-api/system/tuser/update', method: 'post', data: row})
  }

export const getUser =
  (id) => {
    return request({
      url: '/api/jobslink-api/system/tuser/detail',
      method: 'get',
      params: {
        id,
      }
    })
  }

export const getUserInfo =
  () => {
    return request({
      url: '/api/jobslink-api/system/tuser/info',
      method: 'get',
    })
  }

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

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

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

export const grant =
  (userIds, roleIds) => {
    return request({
      url: '/api/jobslink-api/system/tuser/grant',
      method: 'post',
      params: {
        userIds,
        roleIds,
      }
    })
  }

export const enableUser =
  (ids) => {
    return request(
      {url: '/api/jobslink-api/system/tuser/on', method: 'post', params: {ids}})
  }

export const disableUser =
  (ids) => {
    return request({
      url: '/api/jobslink-api/system/tuser/off',
      method: 'post',
      params: {ids}
    })
  }

export const getUserInfoById = (userId) => {
  return request({
    url: '/api/jobslink-api/system/tuser/info-by-userid',
    method: 'get',
    params: {
      userId,
    }
  })
}
