import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BusinessInfoVO, BusinessInfoForm, BusinessInfoQuery } from '@/api/customer/customerFile/businessInfo/types';

/**
 * 查询客户工商注册信息列表
 * @param query
 * @returns {*}
 */

export const listBusinessInfo = (query?: BusinessInfoQuery): AxiosPromise<BusinessInfoVO[]> => {
  return request({
    url: '/customer/businessInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户工商注册信息详细
 * @param customerId
 */
export const getBusinessInfo = (customerId: string | number): AxiosPromise<BusinessInfoVO> => {
  return request({
    url: '/customer/businessInfo/' + customerId,
    method: 'get'
  });
};

/**
 * 查询客户工商注册信息详细
 * @param customerName
 */
export const getBusinessInfoBycustomerName = (customerName: string): AxiosPromise<BusinessInfoVO> => {
  return request({
    url: '/customer/businessInfo/selectBusinessByCustomerName/' + customerName,
    method: 'get'
  });
};

/**
 * 新增客户工商注册信息
 * @param data
 */
export const addBusinessInfo = (data: BusinessInfoForm) => {
  return request({
    url: '/customer/businessInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户工商注册信息
 * @param data
 */
export const updateBusinessInfo = (data: BusinessInfoForm) => {
  return request({
    url: '/customer/businessInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户工商注册信息
 * @param customerId
 */
export const delBusinessInfo = (customerId: string | number | Array<string | number>) => {
  return request({
    url: '/customer/businessInfo/' + customerId,
    method: 'delete'
  });
};
