import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EnsureVO, EnsureForm, EnsureQuery } from '@/api/product/ensure/types';

/**
 * 查询产品保障项列表
 * @param query
 * @returns {*}
 */

export const listEnsure = (query?: EnsureQuery): AxiosPromise<EnsureVO[]> => {
  return request({
    url: '/product/ensure/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品保障项详细
 * @param id
 */
export const getEnsure = (id: string | number): AxiosPromise<EnsureVO> => {
  return request({
    url: '/product/ensure/' + id,
    method: 'get'
  });
};

/**
 * 新增产品保障项
 * @param data
 */
export const addEnsure = (data: EnsureForm) => {
  return request({
    url: '/product/ensure',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品保障项
 * @param data
 */
export const updateEnsure = (data: EnsureForm) => {
  return request({
    url: '/product/ensure',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品保障项
 * @param id
 */
export const delEnsure = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/ensure/' + id,
    method: 'delete'
  });
};
