From 6ac1791d54aa1d21acde7db7de93e3de5c1c9f49 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Fri, 17 Mar 2023 14:05:58 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E6=9F=A5=E8=AF=A2=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=99=A8=E5=88=97=E8=A1=A8=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metadataAcquisition/adapter.js | 24 ++++++++++++++++++- .../lib/routes/metadataAcquisition/adapter.js | 4 +++- .../metadataAcquisition/containers/adapter.js | 9 +++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api/app/lib/controllers/metadataAcquisition/adapter.js b/api/app/lib/controllers/metadataAcquisition/adapter.js index 7430cfa..5fc86b2 100644 --- a/api/app/lib/controllers/metadataAcquisition/adapter.js +++ b/api/app/lib/controllers/metadataAcquisition/adapter.js @@ -44,8 +44,30 @@ function addAdapter(opts) { } } +function getAdapters(opts) { + return async function (ctx, next) { + const models = ctx.fs.dc.models; + let errMsg = { message: '获取适配器失败' } + try { + let option = { + where: {}, + order: [["id", "desc"]], + } + + const res = await models.Adapter.findAll(option); + ctx.status = 200; + ctx.body = res; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = errMsg + } + } +} + module.exports = { checkConnect, - addAdapter + addAdapter, + getAdapters } \ No newline at end of file diff --git a/api/app/lib/routes/metadataAcquisition/adapter.js b/api/app/lib/routes/metadataAcquisition/adapter.js index c8e6ed1..63bd8c7 100644 --- a/api/app/lib/routes/metadataAcquisition/adapter.js +++ b/api/app/lib/routes/metadataAcquisition/adapter.js @@ -10,5 +10,7 @@ module.exports = function (app, router, opts, AuthCode) { app.fs.api.logAttr['POST/adapter'] = { content: '增加适配器', visible: true }; router.post('/meta/acq/adapter', adapter.addAdapter(opts)) - + //获取适配器列表 + app.fs.api.logAttr['GET/meta/acq/adapters'] = { content: '获取适配器列表', visible: true }; + router.get('/meta/acq/adapters', adapter.getAdapters(opts)); }; diff --git a/web/client/src/sections/metadataAcquisition/containers/adapter.js b/web/client/src/sections/metadataAcquisition/containers/adapter.js index 472f2b9..20ab361 100644 --- a/web/client/src/sections/metadataAcquisition/containers/adapter.js +++ b/web/client/src/sections/metadataAcquisition/containers/adapter.js @@ -14,7 +14,7 @@ const RELATION_DATABASE_TOOL_CONFIG = [{ }] const LatestMetadata = (props) => { - const { history } = props; + const { history, actions, dispatch } = props; const [isModalOpen, setIsModalOpen] = useState(false); const renderRelationalDatabase = () => { @@ -36,7 +36,12 @@ const LatestMetadata = (props) => { const onFinish = (values) => { const { stepOneValues, stepTwoValues } = values; dispatch(actions.metadataAcquisition.addDataSource({ - + name: stepOneValues?.name, + audited: true, + adapter: 1, + mountPath: 1, + description: stepOneValues?.description, + config: stepTwoValues })) }