提交 6c62d63f authored 作者: vipcxj's avatar vipcxj

add: 新增数据源validate和cursor接口,所有接口添加dmPath参数

上级 c3554780
...@@ -18,19 +18,27 @@ export const datasourceApi = (coordinate) => { ...@@ -18,19 +18,27 @@ export const datasourceApi = (coordinate) => {
return { return {
query: partial(calcGlobalDatasource, datasourceName), query: partial(calcGlobalDatasource, datasourceName),
count: partial(countGlobalDatasource, datasourceName), count: partial(countGlobalDatasource, datasourceName),
cursor: partial(cursorGlobalDatasource, datasourceName),
meta: partial(getGlobalDatasourceMeta, datasourceName), meta: partial(getGlobalDatasourceMeta, datasourceName),
update: partial(updateGlobalDatasource, datasourceName), update: partial(updateGlobalDatasource, datasourceName),
create: partial(createGlobalDatasource, datasourceName), create: partial(createGlobalDatasource, datasourceName),
remove: partial(removeGlobalDatasource, datasourceName), remove: partial(removeGlobalDatasource, datasourceName),
validateUpdate: partial(validateUpdateGlobalDatasource, datasourceName),
validateCreate: partial(validateCreateGlobalDatasource, datasourceName),
validateRemove: partial(validateRemoveGlobalDatasource, datasourceName),
}; };
} else if (containerType === 'module') { } else if (containerType === 'module') {
return { return {
query: partial(calcModuleDatasource, containerName, datasourceName), query: partial(calcModuleDatasource, containerName, datasourceName),
count: partial(countModuleDatasource, containerName, datasourceName), count: partial(countModuleDatasource, containerName, datasourceName),
cursor: partial(cursorModuleDatasource, containerName, datasourceName),
meta: partial(getModuleDatasourceMeta, containerName, datasourceName), meta: partial(getModuleDatasourceMeta, containerName, datasourceName),
update: partial(updateModuleDatasource, containerName, datasourceName), update: partial(updateModuleDatasource, containerName, datasourceName),
create: partial(createModuleDatasource, containerName, datasourceName), create: partial(createModuleDatasource, containerName, datasourceName),
remove: partial(removeModuleDatasource, containerName, datasourceName), remove: partial(removeModuleDatasource, containerName, datasourceName),
validateUpdate: partial(validateUpdateModuleDatasource, containerName, datasourceName),
validateCreate: partial(validateCreateModuleDatasource, containerName, datasourceName),
validateRemove: partial(validateRemoveModuleDatasource, containerName, datasourceName),
}; };
} else { } else {
throw new Error(`Unsupported containerType: ${containerType}`); throw new Error(`Unsupported containerType: ${containerType}`);
...@@ -43,39 +51,63 @@ const makeQueryParams = ({ pst, psz, filters = [], sortBys = [], sortTypes = [], ...@@ -43,39 +51,63 @@ const makeQueryParams = ({ pst, psz, filters = [], sortBys = [], sortTypes = [],
let stType = sortTypes.join(','); let stType = sortTypes.join(',');
stType = stType || undefined; stType = stType || undefined;
return [ return [
...toPairs({ pst, psz }), ...toPairs({ pst, psz, stBy, stType }),
...parseFilters(filters), ...parseFilters(filters),
['stBy', stBy],
['stType', stType],
...normParams(mapKeys(params, (v, k) => `p-${k}`)), ...normParams(mapKeys(params, (v, k) => `p-${k}`)),
].filter(v => v && !isUndefined((v[1]))); ].filter(v => v && !isUndefined((v[1])));
}; };
export async function calcGlobalDatasource(name, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {} }) { const makeParams = (params, { filters = [], sortBys = [], sortTypes = [], qParams = {} }) => {
return request(`/api/datasource/${name}`, makeQueryParams({ pst, psz, filters, sortBys, sortTypes, params })); return [
...toPairs(params),
...makeQueryParams({ filters, sortBys, sortTypes, qParams }),
];
};
export async function calcGlobalDatasource(name, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) {
return request(`/api/datasource/${name}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params }));
}
export async function countGlobalDatasource(name, { filters = [], params = {}, dmPath }) {
return request(`/api/datasource/${name}/count`, makeParams({ dmPath }, { filters, params }));
} }
export async function countGlobalDatasource(name, { filters = [], params = {} }) { export async function cursorGlobalDatasource(name, key, params = {}, dmPath) {
return request(`/api/datasource/${name}/count`, makeQueryParams({ filters, params })); return request(`/api/datasource/${name}/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function updateGlobalDatasource(name, key, params = {}) { export async function validateUpdateGlobalDatasource(name, key, params = {}, dmPath) {
return request(`/api/datasource/${name}/update/validate`, makeParams({ key, dmPath }, { params }));
}
export async function updateGlobalDatasource(name, key, params = {}, dmPath) {
return post(`/api/datasource/${name}/update`, { return post(`/api/datasource/${name}/update`, {
key, key,
params, params,
dmPath,
}); });
} }
export async function createGlobalDatasource(name, params = {}) { export async function validateCreateGlobalDatasource(name, params = {}, dmPath) {
return request(`/api/datasource/${name}/create/validate`, makeParams({ dmPath }, { params }));
}
export async function createGlobalDatasource(name, params = {}, dmPath) {
return post(`/api/datasource/${name}/create`, { return post(`/api/datasource/${name}/create`, {
params, params,
dmPath,
}); });
} }
export async function removeGlobalDatasource(name, key, params = {}) { export async function validateRemoveGlobalDatasource(name, key, params = {}, dmPath) {
return request(`/api/datasource/${name}/remove/validate`, makeParams({ key, dmPath }, { params }));
}
export async function removeGlobalDatasource(name, key, params = {}, dmPath) {
return post(`/api/datasource/${name}/remove`, { return post(`/api/datasource/${name}/remove`, {
key, key,
params, params,
dmPath,
}); });
} }
...@@ -83,31 +115,50 @@ export async function getGlobalDatasourceMeta(name) { ...@@ -83,31 +115,50 @@ export async function getGlobalDatasourceMeta(name) {
return request(`/api/datasource/${name}/meta`); return request(`/api/datasource/${name}/meta`);
} }
export async function calcModuleDatasource(mdName, dsName, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {} }) { export async function calcModuleDatasource(mdName, dsName, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) {
return request(`/api/module/user/${mdName}/datasource/${dsName}`, makeQueryParams({ pst, psz, filters, sortBys, sortTypes, params })); return request(`/api/module/user/${mdName}/datasource/${dsName}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params }));
}
export async function countModuleDatasource(mdName, dsName, { filters = [], params = {}, dmPath }) {
return request(`/api/module/user/${mdName}/datasource/${dsName}/count`, makeParams({ dmPath }, { filters, params }));
}
export async function cursorModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`/api/module/user/${mdName}/datasource/${dsName}/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function countModuleDatasource(mdName, dsName, { filters = [], params = {} }) { export async function validateUpdateModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`/api/module/user/${mdName}/datasource/${dsName}/count`, makeQueryParams({ filters, params })); return request(`/api/module/user/${mdName}/datasource/${dsName}/update/validate`, makeParams({ key, dmPath }, { params }));
} }
export async function updateModuleDatasource(mdName, dsName, key, params = {}) { export async function updateModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return post(`/api/module/user/${mdName}/datasource/${dsName}/update`, { return post(`/api/module/user/${mdName}/datasource/${dsName}/update`, {
key, key,
params, params,
dmPath,
}); });
} }
export async function createModuleDatasource(mdName, dsName, params = {}) { export async function validateCreateModuleDatasource(mdName, dsName, params = {}, dmPath) {
return request(`/api/module/user/${mdName}/datasource/${dsName}/create/validate`, makeParams({ dmPath }, { params }));
}
export async function createModuleDatasource(mdName, dsName, params = {}, dmPath) {
return post(`/api/module/user/${mdName}/datasource/${dsName}/create`, { return post(`/api/module/user/${mdName}/datasource/${dsName}/create`, {
params, params,
dmPath,
}); });
} }
export async function removeModuleDatasource(mdName, dsName, key, params = {}) { export async function validateRemoveModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`/api/module/user/${mdName}/datasource/${dsName}/remove/validate`, makeParams({ key, dmPath }, { params }));
}
export async function removeModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return post(`/api/module/user/${mdName}/datasource/${dsName}/remove`, { return post(`/api/module/user/${mdName}/datasource/${dsName}/remove`, {
key, key,
params, params,
dmPath,
}); });
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论