text: import request from '@/libs/request'
  import { getToken } from '@/libs/util'
  /**
   * 用户登录
   * @param username
   * @param password
   */
  export const login = ({ username, password }) => {
    const data = {
      username,
      password
    }
    return request({
      url: '/api/jwt/token',
      data,
      method: 'post'
    })
  }
  
  /**
   * 登出
   */
  export const logout = () => {
    return request({
      url: 'admin/logout/token',
      data: { token: getToken() },
      method: 'post'
    })
  }
  
  /**
   * 获取用户信息
   */
  export const getUserInfo = () => {
    return request({
      url: 'api/user/front/info',
      params: { token: getToken() },
      method: 'get'
    })
  }
  
  /**
   * 获取登录用户菜单权限
   */
  export const getCurrentUserMenu = () => {
    return request({
      url: 'api/user/front/menus',
      params: { token: getToken() },
      method: 'get'
    })
  }
  
  export const updateCurrentUserInfo = ({ nickName, userDesc, avatar }) => {
    const data = {
      nickName: nickName,
      userDesc: userDesc,
      avatar: avatar
    }
    return request({
      url: 'base/current/user/update',
      data,
      method: 'post'
    })
  }
  
  /**
   * 获取用户列表
   * @param page
   * @param limit
   */
  export const getUsers = (params) => {
    return request({
      url: 'base/user',
      params,
      method: 'get'
    })
  }
  
  /**
   * 获取所有用户列表
   */
  export const getAllUsers = () => {
    return request({
      url: 'base/user/all',
      method: 'get'
    })
  }
  
  /**
   * 添加用户信息
   * @param userName
   * @param password
   * @param nickName
   * @param status
   * @param userType
   * @param email
   * @param mobile
   * @param userDesc
   * @param avatar
   */
  export const addUser = ({ userName, password, nickName, status, userType, email, mobile, userDesc, avatar }) => {
    const data = {
      userName: userName,
      nickName: nickName,
      password: password,
      status: status,
      userType: userType,
      email: email,
      mobile: mobile,
      userDesc: userDesc,
      avatar: avatar
    }
    return request({
      url: 'base/user/add',
      data,
      method: 'post'
    })
  }
  
  /**
   * 更新用户信息
   * @param userId
   * @param nickName
   * @param status
   * @param userType
   * @param email
   * @param mobile
   * @param userDesc
   * @param avatar
   */
  export const updateUser = ({ userId, nickName, status, userType, email, mobile, userDesc, avatar }) => {
    const data = {
      userId: userId,
      nickName: nickName,
      status: status,
      userType: userType,
      email: email,
      mobile: mobile,
      userDesc: userDesc,
      avatar: avatar
    }
    return request({
      url: 'base/user/update',
      data,
      method: 'post'
    })
  }
  
  /**
   * 分配用户角色
   * @param data
   */
  export const addUserRoles = ({ userId, grantRoles }) => {
    const data = { userId: userId, roleIds: grantRoles.join(',') }
    return request({
      url: 'base/user/roles/add',
      data,
      method: 'post'
    })
  }
  
  /**
   * 获取用户角色
   * @param userId
   */
  export const getUserRoles = (userId) => {
    const params = {
      userId: userId
    }
    return request({
      url: 'base/user/roles',
      params,
      method: 'get'
    })
  }
  
  /**
   * 修改密码
   * @param userId
   * @param oldPassword
   * @param newPassword
   */
  export const updatePassword = ({ userId, password }) => {
    const data = {
      userId: userId,
      password: password
    }
    return request({
      url: 'base/user/update/password',
      data,
      method: 'post'
    })
  }
  