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 f7367ab..57b4a20 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -110,7 +110,8 @@ 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' }); ResourceConsumption.belongsTo(MetadataFile, { foreignKey: 'resourceId', targetKey: 'id' }); diff --git a/web/client/src/sections/backups/nav-item.js b/web/client/src/sections/backups/nav-item.js index 0b80f0a..fc6b81c 100644 --- a/web/client/src/sections/backups/nav-item.js +++ b/web/client/src/sections/backups/nav-item.js @@ -7,7 +7,7 @@ const SubMenu = Menu.SubMenu; export function getNavItem(user) { return ( - user?.role == '系统管理员' && } title='数据备份恢复'> + user?.username == 'SuperAdmin' && } title='数据备份恢复'> 备份恢复 diff --git a/web/client/src/sections/memberManagement/nav-item.js b/web/client/src/sections/memberManagement/nav-item.js index 56c3fd0..baa19f7 100644 --- a/web/client/src/sections/memberManagement/nav-item.js +++ b/web/client/src/sections/memberManagement/nav-item.js @@ -7,7 +7,7 @@ const SubMenu = Menu.SubMenu; export function getNavItem(user) { return ( - user?.role == '系统管理员' && } key="auth"> + user?.username == 'SuperAdmin' && } key="auth"> 用户管理 // user?.role == '系统管理员' && } title='用户管理'> diff --git a/web/client/src/sections/metadataAcquisition/nav-item.js b/web/client/src/sections/metadataAcquisition/nav-item.js index 1d9a4a9..d30281b 100644 --- a/web/client/src/sections/metadataAcquisition/nav-item.js +++ b/web/client/src/sections/metadataAcquisition/nav-item.js @@ -6,7 +6,7 @@ const SubMenu = Menu.SubMenu; export function getNavItem(user) { return ( - user?.role == '系统管理员' && } title='元数据采集'> + user?.username == 'SuperAdmin' && } title='元数据采集'> 适配器管理 diff --git a/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js b/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js index 376f38f..07af42f 100644 --- a/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js +++ b/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js @@ -6,7 +6,7 @@ const basicInfo = [{ name: '元数据名称:', key: 'name' }, { name: '上下文路径:', key: 'path' }, { name: '元数据详情:', key: 'description' }]; const BusinessDatabaseModal = (props) => { - const { onConfirm, onCancel, editData, metadataModels, resourceCatalogPath, businessType } = props; + const { onConfirm, onCancel, editData, metadataModels, resourceCatalogPath, businessType, isAdmin } = props; const [form] = Form.useForm(); useEffect(() => { }, []); @@ -66,6 +66,7 @@ const BusinessDatabaseModal = (props) => { return ( handleOk(null)} onCancel={onCancel}> {editData.record && editData.record.businessMetadata.length ? @@ -87,7 +88,7 @@ const BusinessDatabaseModal = (props) => { ({ getFieldValue, validateFields }) => ({ validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, item.name) } })]}> - + )} diff --git a/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js b/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js index f9de168..17ccef9 100644 --- a/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessDatabaseTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -201,13 +201,13 @@ const BusinessDatabaseTable = (props) => { if (record.businessMetadataDatabases.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataDatabases[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -329,7 +329,8 @@ const BusinessDatabaseTable = (props) => { editData={editData} onCancel={() => setModalVisible(false)} onConfirm={onConfirm} - resourceCatalogPath={resourceCatalogPath} /> : '' + resourceCatalogPath={resourceCatalogPath} + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessFilesTable.js b/web/client/src/sections/metadataManagement/containers/businessFilesTable.js index 49e91bb..bc18f9d 100644 --- a/web/client/src/sections/metadataManagement/containers/businessFilesTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessFilesTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessFilesTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -190,13 +190,13 @@ const BusinessFilesTable = (props) => { if (record.businessMetadataFiles.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataFiles[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -317,7 +317,8 @@ const BusinessFilesTable = (props) => { onCancel={() => setModalVisible(false)} onConfirm={onConfirm} resourceCatalogPath={resourceCatalogPath} - businessType='文件' /> : '' + businessType='文件' + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessMetadata.js b/web/client/src/sections/metadataManagement/containers/businessMetadata.js index 23e115d..67be5d6 100644 --- a/web/client/src/sections/metadataManagement/containers/businessMetadata.js +++ b/web/client/src/sections/metadataManagement/containers/businessMetadata.js @@ -4,10 +4,12 @@ import { Spin, Row, Col, Tree, Tooltip, Input } from 'antd'; import BusinessTab from './businessTab'; let expandedKeysData = []; let allTreeNodeKeys = []; +let resourceCatalogRawData = []; const BusinessMetadata = (props) => { const { user, dispatch, actions, clientHeight, isRequesting, resourceCatalog } = props; const { metadataManagement } = actions; + const [isAdmin, setIsAdmin] = useState(false); const [resourceCatalogData, setResourceCatalogData] = useState([]); const [selectedKeys, setSelectedKeys] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]); @@ -23,6 +25,7 @@ const BusinessMetadata = (props) => { dispatch(metadataManagement.getResourceCatalog()).then(res => { const { data } = res.payload; if (res.success) { + resourceCatalogRawData = data; allTreeNodeKeys = [] const resourceCatalogData = getTreeNodeData(data, null, 'rc', [], null); setResourceCatalogData(resourceCatalogData); @@ -44,7 +47,10 @@ const BusinessMetadata = (props) => { const keyArr = selectedData[0].split('-'); keyArr.shift();//['rc-2-5']->返回'rc';keyArr:['2','5'] const allExpandedKeys = allTreeNodeKeys.filter(k => keyArr.includes(k.id.toString())); - setResourceCatalogId(keyArr.pop()); + const resourceCatalogId = keyArr.pop(); + setResourceCatalogId(resourceCatalogId); + setIsAdmin(user?.username === 'SuperAdmin' + || (user?.role === '系统管理员' && user?.orgId == resourceCatalogRawData.find(a => a.id == resourceCatalogId)?.orgId)); setResourceCatalogKey(selectedData[0]); const resourceCatalogPath = allExpandedKeys.map(a => a.name); setResourceCatalogPath(resourceCatalogPath); @@ -161,7 +167,8 @@ const BusinessMetadata = (props) => { + resourceCatalogPath={resourceCatalogPath} + isAdmin={isAdmin} /> diff --git a/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js b/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js index 7c79801..0c8e8c6 100644 --- a/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessFilesTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -190,13 +190,13 @@ const BusinessFilesTable = (props) => { if (record.businessMetadataRestapis.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataRestapis[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -317,7 +317,8 @@ const BusinessFilesTable = (props) => { onCancel={() => setModalVisible(false)} onConfirm={onConfirm} resourceCatalogPath={resourceCatalogPath} - businessType='接口' /> : '' + businessType='接口' + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessTab.js b/web/client/src/sections/metadataManagement/containers/businessTab.js index 2fcda8f..cfca376 100644 --- a/web/client/src/sections/metadataManagement/containers/businessTab.js +++ b/web/client/src/sections/metadataManagement/containers/businessTab.js @@ -6,7 +6,7 @@ import BusinessFilesTable from './businessFilesTable'; import BusinessRestapisTable from './businessRestapisTable'; const BusinessTab = (props) => { - const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch } = props; + const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch, isAdmin } = props; const [activeKey, setActiveKey] = useState('databases'); useEffect(() => { setActiveKey('databases'); @@ -36,11 +36,11 @@ const BusinessTab = (props) => { { activeKey === 'databases' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : activeKey === 'files' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : activeKey === 'restapis' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : null } diff --git a/web/client/src/sections/metadataManagement/containers/databasesTable.js b/web/client/src/sections/metadataManagement/containers/databasesTable.js index 8f3b569..2099041 100644 --- a/web/client/src/sections/metadataManagement/containers/databasesTable.js +++ b/web/client/src/sections/metadataManagement/containers/databasesTable.js @@ -11,7 +11,7 @@ import MetadataResourceModal from '../components/metadataResourceModal'; import ReleaseModal from '../components/releaseModal'; const DatabaseTable = (props) => { - const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey, + const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey, isAdmin, resourceCatalogPath, isRequesting, metadataModels, setView, tagList, metadataResourceApplications, params } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; @@ -182,7 +182,7 @@ const DatabaseTable = (props) => { ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id); return onView(record)}>查看 - {user.role == '数据消费者' ? null : + {!isAdmin ? null : <> onEdit(record)}>编辑 { {record.type === '表' ? marking(record.id)}>打标 : null} } - - {user.role !== '数据消费者' ? null : record.type === '表' ? resourceApplicationsRecords.length === 0 ? + {isAdmin ? null : record.type === '表' ? resourceApplicationsRecords.length === 0 ? applyResources(record)}>申请资源 : 申请资源 : null} - {user.role == '数据消费者' ? null : + {!isAdmin ? null : record.type === '表' ? servicePublication(record)}>REST服务发布 : null } @@ -272,7 +271,7 @@ const DatabaseTable = (props) => { return - {user.role == '数据消费者' ? null : <> + {!isAdmin ? null : <> } { : + match={match} + isAdmin={isAdmin} /> : // { - const { user, actions, dispatch, clientHeight, metadataModels, isRequesting, resourceCatalogPath, match } = props; + const { user, actions, dispatch, clientHeight, metadataModels, isRequesting, resourceCatalogPath, match, isAdmin } = props; const { metadataManagement } = actions; const [activeKey, setActiveKey] = useState('info'); const [databasesRecord, setDatabasesRecord] = useState(null); @@ -108,7 +108,7 @@ const MetadataDetails = (props) => { return databasesRecord && (ConfigurableTypes['表'].includes(databasesRecord.type) || databasesRecord.type === '视图') ? null :
- {user?.role == '系统管理员' && } diff --git a/web/client/src/sections/metadataManagement/containers/metadataTab.js b/web/client/src/sections/metadataManagement/containers/metadataTab.js index a79a43d..ed61f76 100644 --- a/web/client/src/sections/metadataManagement/containers/metadataTab.js +++ b/web/client/src/sections/metadataManagement/containers/metadataTab.js @@ -7,7 +7,7 @@ import RestapisTable from './restapisTable'; import { push } from 'react-router-redux'; const MetadataTab = (props) => { - const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch, params } = props; + const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch, params, isAdmin } = props; const [activeKey, setActiveKey] = useState(params?.type || 'databases'); useEffect(() => { if (!params?.type) @@ -42,11 +42,11 @@ const MetadataTab = (props) => { { activeKey === 'databases' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} setView={onView} isAdmin={isAdmin} /> : activeKey === 'files' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : activeKey === 'restapis' && resourceCatalogId ? < RestapisTable params={params} resourceCatalogId={resourceCatalogId} - resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} /> : null + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : null }
} diff --git a/web/client/src/sections/metadataManagement/containers/restapisTable.js b/web/client/src/sections/metadataManagement/containers/restapisTable.js index 7824a79..a8cea8b 100644 --- a/web/client/src/sections/metadataManagement/containers/restapisTable.js +++ b/web/client/src/sections/metadataManagement/containers/restapisTable.js @@ -8,7 +8,7 @@ import MetadataResourceModal from '../components/metadataResourceModal'; const RestapisTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey, - isRequesting, metadataModels, tagList, metadataResourceApplications, params } = props; + isRequesting, metadataModels, tagList, metadataResourceApplications, params, isAdmin } = props; const { metadataManagement } = actions; const [tableData, setTableData] = useState([]); const [tableDataCount, setTableDataCount] = useState(0);//Table数据 @@ -143,7 +143,7 @@ const RestapisTable = (props) => { let resourceApplicationsRecords = metadataResourceApplications.filter(ra => ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id && !!record.token); return - {user.role == '数据消费者' ? null : + {!isAdmin ? null : <> onEdit(record)}>编辑 { } - {user.role == '系统管理员' ? '' : resourceApplicationsRecords.length === 0 ? + {isAdmin ? '' : resourceApplicationsRecords.length === 0 ? applyResources(record)}>申请资源 : 申请资源} @@ -187,7 +187,7 @@ const RestapisTable = (props) => { return - {user.role == '数据消费者' ? null : <>