import request from '@/utils/request'

// 获取用户列表
export const getUserList = (data) => {
  return request({
    url: '/api/permission/Users',
    method: 'GET',
    data
  })
}

// 获取所有用户列表
export const UserListAll = () => {
  return request({
    url: '/api/permission/Users/All',
    method: 'GET'
  })
}

// 获取用户下拉框列表(公司+部门+用户)
export const getUserSelector = () => {
  return request({
    url: '/api/permission/Users/Selector',
    method: 'GET'
  })
}

// 新建用户
export const createUser = (data) => {
  return request({
    url: '/api/permission/Users',
    method: 'POST',
    data
  })
}

// 修改用户
export const updateUser = (data) => {
  return request({
    url: `/api/permission/Users/${data.id}`,
    method: 'PUT',
    data
  })
}

// 获取用户信息
export const getUserInfo = (id) => {
  return request({
    url: `/api/permission/Users/${id}`,
    method: 'GET'
  })
}

// 删除用户
export const delUser = (id) => {
  return request({
    url: `/api/permission/Users/${id}`,
    method: 'DELETE'
  })
}

// 修改用户密码
export const resetUserPassword = (data) => {
  return request({
    url: `/api/permission/Users/${data.id}/Actions/ResetPassword`,
    method: 'POST',
    data
  })
}

// 更新用户状态
export const updateUserState = (id) => {
  return request({
    url: `/api/permission/Users/${id}/Actions/State`,
    method: 'PUT'
  })
}

// IM通讯获取用户
export const getImUser = (data) => {
  return request({
    url: '/api/permission/Users/ImUser',
    method: 'GET',
    data
  })
}

// 获取用户下拉框列表
export const getImUserSelector = (organizeId, keyword) => {
  return request({
    url: `/visual-api/paas/permission/Users/ImUser/Selector/${organizeId}`,
    method: 'post',
    data: { keyword }
  })
}

// 获取组织架构信息
export const getsysUserSelector = (parentId) => {
  return request({
    url: '/api/blade-system/dept/lazy-tree',
    method: 'get',
    params: {
      parentId
    }
  })
}

// 通过组织架构信息获取用户信息
export const getsysUserInfo = (realName, deptId) => {
  return request({
    url: '/api/blade-user/page',
    method: 'get',
    params: {
      realName,
      deptId,
      current: 1,
      size: 1000
    }
  })
}

// 获取用户基本信息
export const getUserInfoList = (userIds) => {
  return request({
    url: '/api/blade-user/getUserList',
    method: 'get',
    params: { userIds }
  })
}
