import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DesignFieldMappingVO, DesignFieldMappingForm, DesignFieldMappingQuery } from '@/api/system/designFieldMapping/types';

/**
 * 查询大屏设计字段映射列表
 * @param query
 * @returns {*}
 */

export const listDesignFieldMapping = (query?: DesignFieldMappingQuery): AxiosPromise<DesignFieldMappingVO[]> => {
  return request({
    url: '/system/designFieldMapping/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询大屏设计字段映射详细
 * @param fieldMappingId
 */
export const getDesignFieldMapping = (fieldMappingId: string | number): AxiosPromise<DesignFieldMappingVO> => {
  return request({
    url: '/system/designFieldMapping/' + fieldMappingId,
    method: 'get'
  });
};

/**
 * 新增大屏设计字段映射
 * @param data
 */
export const addDesignFieldMapping = (data: DesignFieldMappingForm) => {
  return request({
    url: '/system/designFieldMapping',
    method: 'post',
    data: data
  });
};

/**
 * 修改大屏设计字段映射
 * @param data
 */
export const updateDesignFieldMapping = (data: DesignFieldMappingForm) => {
  return request({
    url: '/system/designFieldMapping',
    method: 'put',
    data: data
  });
};

/**
 * 删除大屏设计字段映射
 * @param fieldMappingId
 */
export const delDesignFieldMapping = (fieldMappingId: string | number | Array<string | number>) => {
  return request({
    url: '/system/designFieldMapping/' + fieldMappingId,
    method: 'delete'
  });
};


/**
 * 下拉框查询大屏设计字段映射列表
 * @param query
 * @returns {*}
 */
export function getSysDesignFieldMappingList (query) {
    return request({
        url: '/system/designFieldMapping/getSysDesignFieldMappingList',
        method: 'get',
        params: query
    });
};

/**
 * 大屏设计输出字段参考字段映射接口
 * @param data
 */
export const getDataSourceFieldMappingList = (data) => {
  return request({
    url: '/system/designFieldMapping/getDataSourceFieldMappingList',
    method: 'post',
    data: data
  });
};
