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

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

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

/**
 * 查询供应商工商注册信息详细
 * @param supplierId
 */
export const getBusinessInfo = (supplierId: string | number): AxiosPromise<BusinessInfoVO> => {
  return request({
    url: '/suuplier/sbusinessInfo/' + supplierId,
    method: 'get'
  });
};

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

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

/**
 * 删除供应商工商注册信息
 * @param supplierId
 */
export const delBusinessInfo = (supplierId: string | number | Array<string | number>) => {
  return request({
    url: '/suuplier/sbusinessInfo/' + supplierId,
    method: 'delete'
  });
};

/**
 * 获取工商信息
 * @param enterpriseName 企业名称
 */
export const getBusinessInformation = (enterpriseName: string) => {
  return request({
    url: '/customer/bussineInfo/getinformation',
    method: 'post',
    params: {
      enterpriseName
    }
  });
};
