import request from '@/utils/request'

export function addOrEdit(data) {
  return request({
    url: '/his/storeProduct/addOrEdit',
    method: 'post',
    data: data
  })
}
export function genFormatAttr(productId,json) {
  return request({
    url: '/his/storeProduct/genFormatAttr/'+productId,
    method: 'post',
    data: json
  })
}
export function getAllStoreProductRule() {
  return request({
    url: '/his/storeProduct/getAllStoreProductRule',
    method: 'get'
  })
}

// 下载导入模板
export function importTemplate() {
  return request({
    url: '/his/storeProduct/importTemplate',
    method: 'get'
  })
}
// 查询商品列表
export function listProduct(query) {
  return request({
    url: '/his/storeProduct/list',
    method: 'get',
    params: query
  })
}
// 查询商品商店列表
export function listStore() {
  return request({
    url: '/his/storeProduct/storeList',
    method: 'get'
  })
}
// 查询商品详细
export function getProduct(productId) {
  return request({
    url: '/his/storeProduct/' + productId,
    method: 'get'
  })
}

// 新增商品
export function addProduct(data) {
  return request({
    url: '/his/storeProduct',
    method: 'post',
    data: data
  })
}
export function editPrice(data,price) {
  return request({
    url: '/his/storeProduct/price/'+price,
    method: 'post',
    data: data
  })
}
// 修改商品
export function updateProduct(data) {
  return request({
    url: '/his/storeProduct',
    method: 'put',
    data: data
  })
}

// 删除商品
export function delProduct(productId) {
  return request({
    url: '/his/storeProduct/' + productId,
    method: 'delete'
  })
}

// 导出商品
export function exportProduct(query) {
  return request({
    url: '/his/storeProduct/export',
    method: 'get',
    params: query
  })
}

export function getStoreProductAttrValueList(query) {
  return request({
    url: '/his/storeProduct/getStoreProductAttrValueList',
    method: 'get',
    params: query
  })
}

