import api from './request'

// 认证相关API
export const login = (credentials) => {
  return api.post('/auth/login', credentials)
}

export const register = (userData) => {
  return api.post('/auth/register', userData)
}

export const logout = () => {
  return api.post('/auth/logout')
}

export const getCurrentUser = () => {
  return api.get('/auth/me')
}

// 用户相关API
export const getUsers = (params) => {
  return api.get('/users', { params })
}

export const getUserById = (id) => {
  return api.get(`/users/${id}`)
}

export const createUser = (userData) => {
  return api.post('/users', userData)
}

export const updateUser = (id, userData) => {
  return api.put(`/users/${id}`, userData)
}

export const deleteUser = (id) => {
  return api.delete(`/users/${id}`)
}

// 检查用户名是否存在
export const checkUsernameExists = (username) => {
  return api.get(`/public/users/exists/username`, {
    params: { value: username }
  })
}

// 检查邮箱是否存在
export const checkEmailExists = (email) => {
  return api.get(`/public/users/exists/email`, {
    params: { value: email }
  })
}







