import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContracproductVO, ContracproductForm, ContracproductQuery } from '@/api/product/contractproduct/types';

/**
 * 查询合同产品关联列表
 * @param query
 * @returns {*}
 */

export const listContracproduct = (query?: ContracproductQuery): AxiosPromise<ContracproductVO[]> => {
  return request({
    url: '/product/contracproduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同产品关联详细
 * @param id
 */
export const getContracproduct = (id: string | number): AxiosPromise<ContracproductVO> => {
  return request({
    url: '/product/contracproduct/' + id,
    method: 'get'
  });
};

/**
 * 新增合同产品关联
 * @param data
 */
export const addContracproduct = (data: ContracproductForm) => {
  return request({
    url: '/product/contracproduct',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同产品关联
 * @param data
 */
export const updateContracproduct = (data: ContracproductForm) => {
  return request({
    url: '/product/contracproduct',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同产品关联
 * @param id
 */
export const delContracproduct = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/contracproduct/' + id,
    method: 'delete'
  });
};
