import { request } from '@/api/_service'

const BASE = 'production_configuration/product_model/battery_model/'

function apiParams (method, data = {}) {
  return {
    method: `production_master_data_product_management_product_list_${method}`,
    platform: 'background',
    ...data
  }
}

export function getProductList (data) {
  return request({
    url: BASE + 'list',
    method: 'get',
    params: apiParams('list', data)
  })
}

export function getProductBatteryAll (data) {
  return request({
    url: BASE + 'all',
    method: 'get',
    params: {
      method: 'production_configuration_product_model_battery_model_all',
      platform: 'background',
      ...data
    }
  })
}

export function createProduct (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('create', data)
  })
}

export function editProduct (data) {
  return request({
    url: BASE + 'edit',
    method: 'put',
    data: apiParams('edit', data)
  })
}

export function deleteProduct (data) {
  return request({
    url: BASE + 'delete',
    method: 'delete',
    data: apiParams('delete', data)
  })
}
