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

/**
 * 查询银行信息列表
 * @param query
 * @returns {*}
 */

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

/**
 * 查询银行信息详细
 * @param id
 */
export const getBank = (id: string | number): AxiosPromise<BankVO> => {
  return request({
    url: '/system/bank/' + id,
    method: 'get'
  });
};

/**
 * 新增银行信息
 * @param data
 */
export const addBank = (data: BankForm) => {
  return request({
    url: '/system/bank',
    method: 'post',
    data: data
  });
};

/**
 * 修改银行信息
 * @param data
 */
export const updateBank = (data: BankForm) => {
  return request({
    url: '/system/bank',
    method: 'put',
    data: data
  });
};

/**
 * 删除银行信息
 * @param id
 */
export const delBank = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/bank/' + id,
    method: 'delete'
  });
};

export function changeShowStatus(id: string | number, isShow: string) {
  const data = {
    id,
    isShow
  };
  return request({
    url: '/system/bank/changeStatus',
    method: 'put',
    data: data
  });
}
