import api from './request'

// 获取会员列表
export const getMembers = (params) => {
  return api.get('/members', { params })
}

// 更新会员信息
export const updateMember = (id, data) => {
  return api.put(`/members/${id}`, data)
}

// 删除会员
export const deleteMember = (id) => {
  return api.delete(`/members/${id}`)
}

// 批量删除会员
export const deleteMembers = (ids) => {
  return api.delete('/members/batch', { data: { ids } })
}

// 获取会员详情
export const getMemberDetail = (id) => {
  return api.get(`/members/${id}`)
}

// 获取所有会员等级配置
export const getMembershipLevels = () => {
  return api.get('/members/levels')
}

// 更新会员等级配置
export const updateMembershipLevel = (id, data) => {
  return api.put(`/members/levels/${id}`, data)
}

// 封禁/解封会员
export const toggleBanMember = (id, isActive) => {
  return api.put(`/members/${id}/ban`, { isActive })
}

// 设置用户角色（仅超级管理员可用）
export const setUserRole = (id, role) => {
  return api.put(`/members/${id}/role`, { role })
}
