import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AssociateVO, AssociateForm, AssociateQuery } from '@/api/product/associate/types';

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

export const listAssociate = (query?: AssociateQuery): AxiosPromise<AssociateVO[]> => {
  return request({
    url: '/product/associate/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增产品关联
 * @param data
 */
export const addAssociate = (data: AssociateForm) => {
  return request({
    url: '/product/associate',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品关联
 * @param data
 */
export const updateAssociate = (data: AssociateForm) => {
  return request({
    url: '/product/associate',
    method: 'put',
    data: data
  });
};

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