import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DesignDataSourceVO, DesignDataSourceForm, DesignDataSourceQuery } from '@/api/system/designDataSource/types';

/**
 * 查询大屏设计数据源列表
 * @param query
 * @returns {*}
 */

export const listDesignDataSource = (query?: DesignDataSourceQuery): AxiosPromise<DesignDataSourceVO[]> => {
  return request({
    url: '/system/designDataSource/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询大屏设计数据源详细
 * @param dataSourceId
 */
export const getDesignDataSource = (dataSourceId: string | number): AxiosPromise<DesignDataSourceVO> => {
  return request({
    url: '/system/designDataSource/' + dataSourceId,
    method: 'get'
  });
};

/**
 * 新增大屏设计数据源
 * @param data
 */
export const addDesignDataSource = (data: DesignDataSourceForm) => {
  return request({
    url: '/system/designDataSource',
    method: 'post',
    data: data
  });
};

/**
 * 修改大屏设计数据源
 * @param data
 */
export const updateDesignDataSource = (data: DesignDataSourceForm) => {
  return request({
    url: '/system/designDataSource',
    method: 'put',
    data: data
  });
};

/**
 * 删除大屏设计数据源
 * @param dataSourceId
 */
export const delDesignDataSource = (dataSourceId: string | number | Array<string | number>) => {
  return request({
    url: '/system/designDataSource/' + dataSourceId,
    method: 'delete'
  });
};


/**
 * 下拉框查询大屏设计数据源列表
 * @param query
 * @returns {*}
 */
export function getSysDesignDataSourceList (query) {
    return request({
        url: '/system/designDataSource/getSysDesignDataSourceList',
        method: 'get',
        params: query
    });
};
