提交 b787e0d1 authored 作者: vipcxj's avatar vipcxj

更新数据源相关接口

上级 66acce26
import { mapKeys, toPairs, isUndefined, isString, partial } from 'lodash';
import request, { normParams } from '../utils/request';
import request from '../utils/request';
import post from '../utils/post';
import { normParams } from '../utils/http-helper';
import { split } from '../utils/filter';
const parseFilters = filtersIn => (filtersIn || []).filter(({ filter }) => !!filter).map(({ key, filter }) => [
......@@ -17,12 +19,16 @@ export const datasourceApi = (coordinate) => {
query: partial(calcGlobalDatasource, datasourceName),
count: partial(countGlobalDatasource, datasourceName),
meta: partial(getGlobalDatasourceMeta, datasourceName),
update: partial(updateGlobalDatasource, datasourceName),
create: partial(createGlobalDatasource(), datasourceName),
};
} else if (containerType === 'module') {
return {
query: partial(calcModuleDatasource, containerName, datasourceName),
count: partial(countModuleDatasource, containerName, datasourceName),
meta: partial(getModuleDatasourceMeta, containerName, datasourceName),
update: partial(updateModuleDatasource, containerName, datasourceName),
create: partial(createModuleDatasource, containerName, datasourceName),
};
} else {
throw new Error(`Unsupported containerType: ${containerType}`);
......@@ -51,8 +57,21 @@ export async function countGlobalDatasource(name, { filters = [], params = {} })
return request(`/api/datasource/${name}/count`, makeQueryParams({ filters, params }));
}
export async function updateGlobalDatasource(name, key, params = {}) {
return post(`/api/datasource/${name}/update`, {
key,
params,
});
}
export async function createGlobalDatasource(name, params = {}) {
return post(`/api/datasource/${name}/create`, {
params,
});
}
export async function getGlobalDatasourceMeta(name) {
return request(`/api/datasource/${name}`);
return request(`/api/datasource/${name}/meta`);
}
export async function calcModuleDatasource(mdName, dsName, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {} }) {
......@@ -63,6 +82,20 @@ export async function countModuleDatasource(mdName, dsName, { filters = [], para
return request(`/api/modules/module/${mdName}/datasource/${dsName}/count`, makeQueryParams({ filters, params }));
}
export async function updateModuleDatasource(mdName, dsName, key, params = {}) {
return post(`/api/modules/module/${mdName}/datasource/${dsName}/update`, {
key,
params,
});
}
export async function createModuleDatasource(mdName, dsName, params = {}) {
return post(`/api/modules/module/${mdName}/datasource/${dsName}/create`, {
params,
});
}
export async function getModuleDatasourceMeta(mdName, dsName) {
return request(`/api/modules/module/${mdName}/datasource/${dsName}/meta`);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论