import {get, post} from '../request.js'

const prefix = 'user'

/**
 * 登录
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function loginApi(credentials) {
  return post('login', credentials)
}
/**
 * 注册
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function registerApi(credentials) {
  return post('register', credentials)
}

/**
 * 获取用户列表
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function userListApi(credentials) {
  return get(`${prefix}/list`, credentials)
}

/**
 * 获取当前登录用户信息
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function userMyInfoApi(credentials) {
  return get(`${prefix}/my-info`, credentials)
}

/**
 * 获取用户统计信息
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function userStatsApi(credentials) {
  return get(`${prefix}/user-stats`, credentials)
}

/**
 * 创建用户
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function createUserApi(credentials) {
  return post(`${prefix}/create`, credentials)
}

/**
 * 更新用户
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function updateUserApi(credentials) {
  return post(`${prefix}/update`, credentials)
}

/**
 * 删除用户
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteUserApi(credentials) {
  return post(`${prefix}/delete`, credentials)
}

/**
 * 重置密码
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function resetPasswordApi(credentials) {
  return post(`${prefix}/reset-password`, credentials)
}

/**
 * 重置密码
 * @param credentials
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function changePasswordApi(credentials) {
  return post(`${prefix}/change-password`, credentials)
}