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

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

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

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

/**
 * 新增公司
 * @param data
 */
export const addCompany = (data: CompanyForm): AxiosPromise<string | number> => {
  return request({
    url: '/materials/company',
    method: 'post',
    data: data
  });
};

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

/**
 * 删除公司
 * @param id
 */
export const delCompany = (id: string | number | Array<string | number>) => {
  return request({
    url: '/materials/company/' + id,
    method: 'delete'
  });
};
