import request from '@/utils/request'

export function login (username, password) {
  return request({
    url: '/seer/admin/user/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

export function getInfo() {
  return request({
    url: '/seer/admin/user/info',
    method: 'get'
  })
}

export function logout () {
  return request({
    url: '/seer/admin/user/logout',
    method: 'post'
  })
}

export function fetchList (params) {
  return request({
    url: `/seer/admin/user/list/${params.pageNum}/${params.pageSize}`,
    method: 'get',
    params: {
      userName: params.keyword
    }
  })
}

export function createAdmin (data) {
  return request({
    url: '/seer/admin/user/register',
    method: 'post',
    data: data
  })
}

export function updateAdmin (id, data) {
  return request({
    url: '/seer/admin/user/update/' + id,
    method: 'post',
    data: data
  })
}

export function updateStatus (id, params) {
  return request({
    url: '/seer/admin/user/updateStatus/' + id,
    method: 'post',
    params: params
  })
}

export function deleteAdmin (id) {
  return request({
    url: '/seer/admin/user/delete/' + id,
    method: 'post'
  })
}

export function getRoleByAdmin (id) {
  return request({
    url: `/seer/admin/user/role/${id}`,
    method: 'get'
  })
}

export function allocRole (data) {
  return request({
    url: '/seer/admin/user/role/update',
    method: 'post',
    data: data
  })
}
