import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractorForm, ContractorQuery, ContractorVO } from '@/api/project/contractor/types';

/**
 * 查询分包单位列表
 * @param query
 * @returns {*}
 */

export const listContractor = (query?: ContractorQuery): AxiosPromise<ContractorVO[]> => {
  return request({
    url: '/project/contractor/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分包单位详细
 * @param id
 */
export const getContractor = (id: string | number): AxiosPromise<ContractorVO> => {
  return request({
    url: '/project/contractor/' + id,
    method: 'get'
  });
};

/**
 * 新增分包单位
 * @param data
 */
export const addContractor = (data: ContractorForm): AxiosPromise<string | number> => {
  return request({
    url: '/project/contractor',
    method: 'post',
    data: data
  });
};

/**
 * 修改分包单位
 * @param data
 */
export const updateContractor = (data: ContractorForm) => {
  return request({
    url: '/project/contractor',
    method: 'put',
    data: data
  });
};

/**
 * 删除分包单位
 * @param id
 */
export const delContractor = (id: string | number | Array<string | number>) => {
  return request({
    url: '/project/contractor/' + id,
    method: 'delete'
  });
};
