import http from '@/utils/request'

// 获取商品分组列表
export function getGoodsGroupList (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(`/goodsGroup/?${(pageNum === 0 || pageNum) ? `pageNum=${pageNum}` : ''}&${(pageSize === 0 || pageSize) ? `pageSize=${pageSize}` : ''}&${status}`)
}

// 获取商品分组详情
export function getGoodsGroupDetail (id) {
  return http.get(`/goodsGroup/${id}`)
}
// 添加商品分组
export function addGoodsGroup (params) {
  return http.post('/goodsGroup', params)
}

// 更新商品分组
export function updateGoodsGroup (id, params) {
  return http.post(`/goodsGroup/${id}`, params)
}

// 删除商品分组
export function deleteGoodsGroup (id) {
  return http.delete(`/goodsGroup/${id}`)
}
// 激活或禁用商品分组
export function activeGoodsGroup (id, params) {
  return http.post(`/goodsGroup/${id}/active`, params)
}
