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

export function toLogin(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: 'login',
    method: 'post',
    data: qs.stringify(data)
  })
}

export function getInfo(token) {
  return request({
    url: '/user/get',
    method: 'post'
  })
}

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

export function getList(params) {
  return request({
    url: '/user/list',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function updateRole(params) {
  return request({
    url: '/user/add/role',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function getRole(params) {
  return request({
    url: '/user/get/role',
    method: 'post',
    data: qs.stringify(params)
  })
}
export function add(params) {
  return request({
    url: '/user/config/save',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function getuserList(params) {
  return request({
    url: '/user/config/list',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function deluser(params) {
  return request({
    url: '/user/config/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function updateUser(params) {
  return request({
    url: '/user/config/update',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function download(params) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/user/config/download',
    responseType: 'blob',
    method: 'post',
    data: qs.stringify(params)
  })
}
