import request from '@/utils/request'

/**
 * @Author: NanKeYang
 * @Description: 用户相关API
 * @Data: 2019/10/8 15:43
 */

/**
 * @Author: NanKeYang
 * @Description: 登录
 * @Data: 2019/10/8 10:19
 */
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

// export function getInfo(token) {
//   return request({
//     url: 'http://localhost:9527/mock/user/info',
//     method: 'get',
//     params: { token }
//   })
// }

/**
 * @Author: NanKeYang
 * @Description: 退出登录
 * @Data: 2019/10/8 10:19
 */
export function logout() {
  return request({
    url: '/logout',
    method: 'get'
  })
}

/**
 * @Author: NanKeYang
 * @Description: 添加
 * @Data: 2019/10/8 10:20
 */
export function add(data) {
  return request({
    url: '/user/add',
    method: 'post',
    data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 更新
 * @Data: 2019/10/8 10:20
 */
export function update(data) {
  return request({
    url: '/user/edit',
    method: 'post',
    data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 删除
 * @Data: 2019/10/8 10:21
 */
export function remove(data) {
  return request({
    url: '/user/delete',
    method: 'post',
    params: data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 获取列表
 * @Data: 2019/10/8 10:21
 */
export function fetchList(data) {
  return request({
    url: '/user/pageList',
    method: 'get',
    params: data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 获取全部列表
 * @Data: 2019/10/8 10:21
 */
export function fetchAllList() {
  return request({
    url: '/user/list',
    method: 'get'
  })
}

/**
 * @Author: NanKeYang
 * @Description: 获取详情
 * @Data: 2019/10/8 10:21
 */
export function fetchDetail(data) {
  return request({
    url: '/user/view/' + data,
    method: 'get'
  })
}

/**
 * @Author: NanKeYang
 * @Description: 冻结状态更新
 * @Data: 2019/10/8 10:21
 */
export function freezeStatusUpdate(data) {
  return request({
    url: '/user/freeze',
    method: 'post',
    data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 重置密码
 * @Data: 2019/10/8 10:21
 */
export function passwordReset(data) {
  return request({
    url: '/user/reset',
    method: 'post',
    data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 密码修改
 * @Data: 2019/10/8 10:21
 */
export function passwordModify(data) {
  return request({
    url: '/user/changePwd',
    method: 'post',
    data
  })
}

/**
 * @Author: NanKeYang
 * @Description: 修改头像
 * @Data: 2019/10/8 10:21
 */
export function updateAvatar(data) {
  return request({
    url: '/user/editImg',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
