import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CompanyVO, CompanyForm, CompanyQuery } from '@/api/company/company/types';

/**
 * 查询公司信息列表
 * @param query
 * @returns {*}
 */

export const listCompany = (query?: CompanyQuery): AxiosPromise<CompanyVO[]> => {
  return request({
    url: '/system/company/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询公司信息详细
 * @param id
 */
export const getCompany = (id: string | number): AxiosPromise<CompanyVO> => {
  return request({
    url: '/system/company/' + id,
    method: 'get'
  });
};

/**
 * 新增公司信息
 * @param data
 */
export const addCompany = (data: CompanyForm) => {
  return request({
    url: '/system/company',
    method: 'post',
    data: data
  });
};

/**
 * 修改公司信息
 * @param data
 */
export const updateCompany = (data: CompanyForm) => {
  return request({
    url: '/system/company',
    method: 'put',
    data: data
  });
};

/**
 * 删除公司信息
 * @param id
 */
export const delCompany = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/company/' + 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
  });
}
