import request from '@/utils/request'

// 查询用户列表
export function listUser(query) {
  return request({
    url: '/cai/user/list',
    method: 'get',
    params: query
  })
}

export function resetUserPassword(data) {
  return request({
    url: '/cai/user/resetPwd',
    method: 'post',
    data: data
  })
}

export function userForbid(data) {
  return request({
    url: '/cai/user/userForbid',
    method: 'post',
    data: data
  })
}

export function userResetAvatar(id) {
  return request({
    url: '/cai/user/resetAvatar',
    method: 'post',
    data: {id}
  })
}

export function userResetNickname(id) {
  return request({
    url: '/cai/user/resetNickname',
    method: 'post',
    data: {id}
  })
}

export function resetUserMobile(data) {
  return request({
    url: '/cai/user/updateMobile',
    method: 'put',
    data: data
  })
}

// 查询用户详细
export function getUser(id) {
  return request({
    url: '/cai/user/' + id,
    method: 'get'
  })
}

export function getFullUser(id) {
  return request({
    url: '/cai/user/full/' + id,
    method: 'get'
  })
}

export function listUserByAnchorUserCode(usercode) {
  return request({
    url: '/cai/user/listByUserCode',
    method: 'get',
    params:{
      usercode: usercode,
      isAnchor: 1,
      limit: 40
    }
  })
}

export function listUserByUserCode(usercode) {
  return request({
    url: '/cai/user/listByUserCode',
    method: 'get',
    params:{
      usercode: usercode,
      limit: 40
    }
  })
}

export function getUserByUsercode(usercode) {
  return request({
    url: '/cai/user/getByUsercode',
    method: 'get',
    params:{
      usercode: usercode
    }
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/cai/user',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/cai/user',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delUser(id) {
  return request({
    url: '/cai/user/' + id,
    method: 'delete'
  })
}

// 解绑用户邀请人
export function userUnBindInvite(userId) {
  return request({
    url: '/cai/user/unBindInvite',
    method: 'get',
    params:{userId}
  })
}

export function userLogout(userId) {
  return request({
    url: '/cai/user/logout',
    method: 'post',
    data:{id:userId}
  })
}

// 绑定用户邀请人
export function userBindInvite(userId,inviteUsercode) {
  return request({
    url: '/cai/user/bindInvite',
    method: 'get',
    params:{
      userId,inviteUsercode
    }
  })
}

export function lockIm(userId) {
  return request({
    url: '/cai/user/lockIm',
    method: 'get',
    params:{
      userId
    }
  })
}

export function unLockIm(userId) {
  return request({
    url: '/cai/user/unLockIm',
    method: 'get',
    params:{
      userId
    }
  })
}

export function noSpeckIm(userId) {
  return request({
    url: '/cai/user/noSpeckIm',
    method: 'get',
    params:{
      userId
    }
  })
}

export function enSpeckIm(userId) {
  return request({
    url: '/cai/user/enSpeckIm',
    method: 'get',
    params:{
      userId
    }
  })
}

export function refreshImInfo(userId) {
  return request({
    url: '/cai/user/refreshImInfo',
    method: 'get',
    params:{
      userId
    }
  })
}

