import request from '@/utils/request'

const userApi = {
  login: '/login',
  logout: '/logout',
  add: '/sys/user/add',
  edit: '/sys/user/edit',
  del: '/sys/user/del',
  page: '/sys/user/pageList',
  getInfo: '/sys/user/getInfo',
  ownRole: '/sys/user/ownRole',
  grantRole: '/sys/user/grantRole'
}

const userPasswordApi = {
  update: '/sys/user/passwordUpdate',
  reset: '/sys/user/resetPwd'
}

export function userLogin (params) {
  return request({
    url: userApi.login,
    method: 'post',
    data: params
  })
}

export function userAdd (params,password) {
  return request({
    url: userApi.add,
    method: 'post',
    data: params,
    params: password
  })
}
export function userEdit (params) {
  return request({
    url: userApi.edit,
    method: 'post',
    data: params
  })
}
export function userDel (params) {
  return request({
    url: userApi.del,
    method: 'post',
    params: params
  })
}
export function userPage (params) {
  return request({
    url: userApi.page,
    method: 'get',
    params: params
  })
}
export function getInfo (params) {
  return request({
    url: userApi.getInfo,
    method: 'post',
    data: params
  })
}
export function userOwnRole (params) {
  return request({
    url: userApi.ownRole,
    method: 'post',
    params: params
  })
}
export function userGrantRole (params) {
  return request({
    url: userApi.grantRole,
    method: 'post',
    data: params
  })
}
export function passwordUpdate (params) {
  return request({
    url: userPasswordApi.update,
    method: 'post',
    data: params
  })
}
export function passwordReset (params) {
  return request({
    url: userPasswordApi.reset,
    method: 'get',
    params: params
  })
}
