import fetchAPI from '../utils/fetch'

export default {
  getRoleList () {
    return fetchAPI('user/roleList/', 'get')
  },
  getUserList (params) {
    return fetchAPI('user/', 'get', null, params)
  },
  createUser (user) {
    return fetchAPI('user/', 'post', user)
  },
  getUser (id) {
    return fetchAPI(`user/${id}/`, 'get')
  },
  updateUser (id, user) {
    return fetchAPI(`user/${id}/`, 'put', user)
  },
  deleteUser (id) {
    return fetchAPI(`user/${id}/`, 'delete')
  },
  checkUsername (username) {
    return fetchAPI('user/checkUsername/', 'get', null, { username })
  }
}