From 5e1e5a8cb4bf2e5abc3356727288373a55655944 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Fri, 3 Nov 2023 09:38:50 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E8=B5=84=E6=BA=90=E6=A3=80=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/auth/index.js | 1 + .../lib/controllers/metadataSearch/index.js | 19 ++++++++++++++++--- api/app/lib/index.js | 3 ++- .../resourceRetrieval/containers/retrieval.js | 16 ++++++++++------ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index ac242fd..1727601 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -56,6 +56,7 @@ async function login(ctx, next) { // await transaction.commit(); } catch (error) { // await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : '登录失败' diff --git a/api/app/lib/controllers/metadataSearch/index.js b/api/app/lib/controllers/metadataSearch/index.js index 9832f1d..edebd92 100644 --- a/api/app/lib/controllers/metadataSearch/index.js +++ b/api/app/lib/controllers/metadataSearch/index.js @@ -15,6 +15,14 @@ function searchMeta(opts) { where['$or'] = [{ name: { $iLike: `%${keywords}%` } } ] } + const resourceCatalogOrganization = { + model: models.ResourceCatalog, + attributes: ['id', 'name'], + include: [{ + model: models.Organization, + attributes: ['id', 'name'], + }] + } const findObj = { include: [ { @@ -22,7 +30,9 @@ function searchMeta(opts) { include: [{ model: models.Tag, }] - }], + }, + resourceCatalogOrganization + ], where: { ...where, type: { $in: ['表', '库'] } @@ -35,7 +45,9 @@ function searchMeta(opts) { include: [{ model: models.Tag, }] - }], + }, + resourceCatalogOrganization + ], where: where } const findObj3 = { @@ -45,7 +57,8 @@ function searchMeta(opts) { include: [{ model: models.Tag, }] - }], + }, + ], where: where } diff --git a/api/app/lib/index.js b/api/app/lib/index.js index 9c0f409..14424bc 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -110,6 +110,7 @@ module.exports.models = function (dc) { MetadataDatabase.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); RestfulApi.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); - + MetadataFile.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); + ResourceCatalog.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' }); }; diff --git a/web/client/src/sections/resourceRetrieval/containers/retrieval.js b/web/client/src/sections/resourceRetrieval/containers/retrieval.js index 9f99eed..38f7846 100644 --- a/web/client/src/sections/resourceRetrieval/containers/retrieval.js +++ b/web/client/src/sections/resourceRetrieval/containers/retrieval.js @@ -201,15 +201,19 @@ function Retrieval(props) {
相关操作: { window.open(`/metadataManagement/latestMetadata?type=${METADTA_TYPE[s.type]}&treeId=${s?.catalog}&resourceId=${s.id}&catalogKey=${s.catalogKey}`) }}>定位 {s?.type == '表' || s?.type == '文件' ? - user?.role == '数据消费者' ? + user?.username !== 'SuperAmin' ? { - const token = approveList?.rows?.find(x => x.resourceId == s.id)?.token - if (!token) { - message.warning('您暂未申请该数据资源,请先申请该数据资源') + const isOrgAdmin = user?.role == '系统管理员' && user?.orgId == s?.resourceCatalog?.organization?.id + if (isOrgAdmin) { + downloadData(s) } else { - setCurrentData(s) + const token = approveList?.rows?.find(x => x.resourceId == s.id)?.token + if (!token) { + message.warning('您暂未申请该数据资源,请先申请该数据资源') + } else { + setCurrentData(s) + } } - }}>下载 : { downloadData(s) }}>下载 : ''}