import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ErpMappingVO, ErpMappingForm, ErpMappingQuery } from '@/api/api/erpMapping/types';

/**
 * 查询ERP接口映射列表
 * @param query
 * @returns {*}
 */

export const listErpMapping = (query?: ErpMappingQuery): AxiosPromise<ErpMappingVO[]> => {
  return request({
    url: '/api/erpMapping/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询ERP接口映射详细
 * @param mappingId
 */
export const getErpMapping = (mappingId: string | number): AxiosPromise<ErpMappingVO> => {
  return request({
    url: '/api/erpMapping/' + mappingId,
    method: 'get'
  });
};

/**
 * 新增ERP接口映射
 * @param data
 */
export const addErpMapping = (data: ErpMappingForm) => {
  return request({
    url: '/api/erpMapping',
    method: 'post',
    data: data
  });
};

/**
 * 修改ERP接口映射
 * @param data
 */
export const updateErpMapping = (data: ErpMappingForm) => {
  return request({
    url: '/api/erpMapping',
    method: 'put',
    data: data
  });
};

/**
 * 删除ERP接口映射
 * @param mappingId
 */
export const delErpMapping = (mappingId: string | number | Array<string | number>) => {
  return request({
    url: '/api/erpMapping/' + mappingId,
    method: 'delete'
  });
};


/**
 * 下拉框查询ERP接口映射列表
 * @param query
 * @returns {*}
 */
export function getSysErpMappingList (query) {
    return request({
        url: '/api/erpMapping/getSysErpMappingList',
        method: 'get',
        params: query
    });
};
