import http from '@/api'
import { ProductVO, ProductForm, ProductQuery } from '@/api/interface/als/product'
/**
 * @name 查询产品树列表
 * @param query 参数
 * @returns 返回列表
 */
export const listProductApi = (query: ProductQuery) => {
  return http.get<ProductVO[]>('/als/product/list', query, { loading: false })
}

/**
 * @name 查询产品树详细
 * @param id id
 * @returns returns
 */
export const getProductApi = (id: string | number) => {
  return http.get<ProductVO>(`/als/product/${id}`)
}

/**
 * @name 新增产品树
 * @param data data
 * @returns returns
 */
export const addProductApi = (data: ProductForm) => {
  return http.post<any>('/als/product', data, { loading: false })
}

/**
 * @name 修改产品树
 * @param data data
 * @returns returns
 */
export const updateProductApi = (data: ProductForm) => {
  return http.put<any>('/als/product', data, { loading: false })
}

/**
 * @name 删除产品树
 * @param id id
 * @returns returns
 */
export const delProductApi = (id: string | number | Array<string | number>) => {
  return http.delete<any>(`/als/product/${id}`)
}

/**
 * @name 下载模板
 * @returns returns
 */
export const importTemplateApi = () => {
  return http.downloadPost('/als/product/importTemplate', {})
}

/**
 * @name 导入数据
 * @returns returns
 */
export const importProductDataApi = (data: any) => {
  return http.post('/als/product/importData', data)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportProductApi = (data: any) => {
  return http.post('/als/product/export', data)
}
