import request from '@/config/axios'

// 产品 VO
export interface ProductVO {
  id: number // 编号
  productName: string // 品种名称
  packageName: string // 包装信息
  specification: string // 规格
  status: number // 状态（1：正常，0：禁用）
}

// 产品 API
export const ProductApi = {
  // 查询产品分页
  getProductPage: async (params: any) => {
    return await request.get({ url: `/visit/product/page`, params })
  },

  // 查询产品详情
  getProduct: async (id: number) => {
    return await request.get({ url: `/visit/product/get?id=` + id })
  },

  // 查询产品详情ByIds
  getProductByIds: async (ids: string) => {
    return await request.get({ url: `/visit/product/getListByIds?ids=` + ids })
  },

  // 新增产品
  createProduct: async (data: ProductVO) => {
    return await request.post({ url: `/visit/product/create`, data })
  },

  // 修改产品
  updateProduct: async (data: ProductVO) => {
    return await request.put({ url: `/visit/product/update`, data })
  },

  // 删除产品
  deleteProduct: async (id: number) => {
    return await request.delete({ url: `/visit/product/delete?id=` + id })
  },

  // 导出产品 Excel
  exportProduct: async (params) => {
    return await request.download({ url: `/visit/product/export-excel`, params })
  },

  // 下载产品信息导入模板
  importProductTemplate: async () => {
    return await request.download({ url: '/visit/product/get-import-template' })
  }
}
