import request from '@/config/axios'

export interface ProductVO {
  id: number
  name: string
  keyword: string
  introduction: string
  description: string
  categoryId: number
  brandId: number
  picUrl: string
  sliderPicUrls: object
  videoUrl: string
  unit: number
  sort: number
  status: number
  price: number
  stock: number
}

// 查询商品信息列表
export const getProductPage = async (params) => {
  return await request.get({ url: `/member/product/page`, params })
}

// 查询商品信息详情
export const getProduct = async (id: number) => {
  return await request.get({ url: `/member/product/get?id=` + id })
}

// 新增商品信息
export const createProduct = async (data: ProductVO) => {
  return await request.post({ url: `/member/product/create`, data })
}

// 修改商品信息
export const updateProduct = async (data: ProductVO) => {
  return await request.put({ url: `/member/product/update`, data })
}

// 删除商品信息
export const deleteProduct = async (id: number) => {
  return await request.delete({ url: `/member/product/delete?id=` + id })
}

// 导出商品信息 Excel
export const exportProduct = async (params) => {
  return await request.download({ url: `/member/product/export-excel`, params })
}

// 根据输入价格查询一个商品
export const getProductByPrice = async (data: any) => {
  return await request.post({ url: `/member/product/get-by-price`, data})
}