import request from '@/utils/request'
import qs from 'qs'

export function login (username, password) {
  let data = {
    username: username,
    password: password,
    grant_type: 'password',
    scope: 'all'
  }
  return request({
    url: '/auth/oauth/token',
    method: 'post',
    headers: {
      'Authorization': 'Basic ZGF0YXg6MTIzNDU2'
    },
    data: qs.stringify(data)
  })
}

export function getRoutes (id) {
  return request({
    url: '/system/users/' + id + '/route',
    method: 'get'
  })
}

export function logout (token) {
  return request({
    url: '/system/logout/' + token,
    method: 'delete'
  })
}

export function listUser (data) {
  return request({
    url: '/system/users/page',
    method: 'get',
    params: data
  })
}
