import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BankVO, BankForm, BankQuery } from '@/api/customer/bank/types';

/**
 * 查询供应商银行账户列表
 * @param query
 * @returns {*}
 */

export const listBank = (query?: BankQuery): AxiosPromise<BankVO[]> => {
  return request({
    url: '/customer/supplierbank/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商银行账户详细
 * @param id
 */
export const getBank = (id: string | number): AxiosPromise<BankVO> => {
  return request({
    url: '/customer/supplierbank/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商银行账户
 * @param data
 */
export const addBank = (data: BankForm) => {
  return request({
    url: '/customer/supplierbank',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商银行账户
 * @param data
 */
export const updateBank = (data: BankForm) => {
  return request({
    url: '/customer/supplierbank',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商银行账户
 * @param id
 */
export const delBank = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/supplierbank/' + id,
    method: 'delete'
  });
};
