import http from '@/utils/request'

// 获取账号列表
export function getLimitGroupList (params) {
  // eslint-disable-next-line prefer-const
  let { pageNum = 1, pageSize = 10, status = ['inactive', 'active'] } = params
  status = status.map(val => {
    return `status=${val}`
  }).join('&')
  return http.get(`/limitgroup/?${(pageNum === 0 || pageNum) ? `pageNum=${pageNum}` : ''}&${(pageSize === 0 || pageSize) ? `pageSize=${pageSize}` : ''}&${status}`)
}

// 获取限购组详情
export function getLimitGroupDetail (id) {
  return http.get(`/limitgroup/${id}`)
}
// 添加限购组
export function addLimitGroup (params) {
  return http.post('/limitgroup', params)
}

// 更新限购组
export function updateLimitGroup (id, params) {
  return http.put(`/limitgroup/${id}`, params)
}

// 删除限购组
export function deleteLimitGroup (id) {
  return http.delete(`/limitgroup/${id}`)
}
// 激活或禁用限购组
export function activeLimitGroup (id, params) {
  return http.post(`/limitgroup/${id}/active`, params)
}

// 更新限购轮次
export function updateLimitRound (id, params) {
  return http.put(`/limitgroup/${id}/round`, params)
}
