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

// 注：BASE URL 与后台 method 名暂沿用旧项目命名，等待后台数据库路由表统一更新
const BASE = 'production_configuration/matetial_model/matetial_category/'

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

// 获取全部物料类别
export function getMaterialCategoryAll (data) {
  return request({
    url: BASE + 'all',
    method: 'get',
    params: apiParams('all', data)
  })
}

// 获取物料类别列表
export function getMaterialCategoryList (data) {
  return request({
    url: BASE + 'list',
    method: 'get',
    params: apiParams('list', data)
  })
}

// 创建物料类别
export function createMaterialCategory (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('create', data)
  })
}

// 编辑物料类别
export function editMaterialCategory (data) {
  return request({
    url: BASE + 'edit',
    method: 'put',
    data: apiParams('edit', data)
  })
}

// 删除物料类别
export function deleteMaterialCategory (data) {
  return request({
    url: BASE + 'delete',
    method: 'delete',
    data: apiParams('delete', data)
  })
}
