import apiRequest from '@/network/http/apiRequest'

export function getUserList() {
  return apiRequest({
    url: '/user/select',
    method: 'GET',
  })
}

/**
 * 分页获取用户
 * @param data
 * @returns
 */
export function getUserByPage(data: any) {
  return apiRequest({
    url: '/user/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 基于群组ID\帐号ID获取用户
 * @param groupId
 * @param accountId
 * @returns
 */
export function getUserById(groupId: number, accountId: number) {
  return apiRequest({
    url: `/user/${groupId}/${accountId}`,
    method: 'GET',
  })
}

/**
 * 添加用户
 * @param data
 * @returns
 */
export function createUser(data: any) {
  return apiRequest({
    url: '/user/add',
    method: 'POST',
    data,
  })
}

/**
 * 更新用户状态
 * @param accountId
 * @param accountStatus
 * @returns
 */
export function updateUserStatus(accountId: number, accountStatus: number) {
  return apiRequest({
    url: `/user/updateStatus/${accountId}/${accountStatus}`,
    method: 'PUT',
  })
}

/**
 * 更新用户
 * @param data
 * @returns
 */
export function updateUser(data: any) {
  return apiRequest({
    url: '/user/update',
    method: 'PUT',
    data,
  })
}

/**
 * 更新密码
 * @param data
 * @returns
 */
export function updatePassword(data: any) {
  return apiRequest({
    url: '/user/updatePassword',
    method: 'PUT',
    data,
  })
}

/**
 * 重置密码
 * @param accountId
 * @returns
 */
export function resetPassword(accountId: number) {
  return apiRequest({
    url: `/user/resetPassword/${accountId}`,
    method: 'PUT',
  })
}

/**
 * 删除用户
 * @param id
 * @return
 */
export function deleteUserById(id: number) {
  return apiRequest({
    url: `/user/${id}`,
    method: 'DELETE',
  })
}

/**
 * 帐号名称是否存在
 * @param accountName
 * @returns
 */
export function isNameExist(accountName: string) {
  return apiRequest({
    url: `/user/isNameExist/${accountName}`,
    method: 'GET',
  })
}

/**
 * 手机号码是否存在
 * @param accountPhone
 * @returns
 */
export function isPhoneExist(accountPhone: string) {
  return apiRequest({
    url: `/user/isPhoneExist/${accountPhone}`,
    method: 'GET',
  })
}

/**
 * 手机号码是否存在
 * @param accountStaffNo
 * @returns
 */
export function isStaffNoExist(accountStaffNo: string) {
  return apiRequest({
    url: `/user/isStaffNoExist/${accountStaffNo}`,
    method: 'GET',
  })
}
