import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PurchaseHabitVO, PurchaseHabitForm, PurchaseHabitQuery } from '@/api/customer/customerFile/purchaseHabit/types';

/**
 * 查询客户采购习惯列表
 * @param query
 * @returns {*}
 */

export const listPurchaseHabit = (query?: PurchaseHabitQuery): AxiosPromise<PurchaseHabitVO[]> => {
  return request({
    url: '/customer/purchaseHabit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户采购习惯详细
 * @param id
 */
export const getPurchaseHabit = (id: string | number): AxiosPromise<PurchaseHabitVO> => {
  return request({
    url: '/customer/purchaseHabit/' + id,
    method: 'get'
  });
};

/**
 * 新增客户采购习惯
 * @param data
 */
export const addPurchaseHabit = (data: PurchaseHabitForm) => {
  return request({
    url: '/customer/purchaseHabit',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户采购习惯
 * @param data
 */
export const updatePurchaseHabit = (data: PurchaseHabitForm) => {
  return request({
    url: '/customer/purchaseHabit',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户采购习惯
 * @param id
 */
export const delPurchaseHabit = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/purchaseHabit/' + id,
    method: 'delete'
  });
};

/**
 * 新增客户采购习惯
 * @param data
 */
export const getCustomerPurchaseHabitData = (customerId: string | number): AxiosPromise<PurchaseHabitVO> => {
  return request({
    url: '/customer/purchaseHabit/getCustomerPurchaseHabitData',
    method: 'get',
    params: {
      customerId: customerId
    }
  });
};
