Browse Source

(*)资源检索功能修改

master
peng.peng 1 year ago
parent
commit
5e1e5a8cb4
  1. 1
      api/app/lib/controllers/auth/index.js
  2. 19
      api/app/lib/controllers/metadataSearch/index.js
  3. 1
      api/app/lib/index.js
  4. 16
      web/client/src/sections/resourceRetrieval/containers/retrieval.js

1
api/app/lib/controllers/auth/index.js

@ -56,6 +56,7 @@ async function login(ctx, next) {
// await transaction.commit(); // await transaction.commit();
} catch (error) { } catch (error) {
// await transaction.rollback(); // await transaction.rollback();
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : '登录失败' message: typeof error == 'string' ? error : '登录失败'

19
api/app/lib/controllers/metadataSearch/index.js

@ -15,6 +15,14 @@ function searchMeta(opts) {
where['$or'] = [{ name: { $iLike: `%${keywords}%` } } where['$or'] = [{ name: { $iLike: `%${keywords}%` } }
] ]
} }
const resourceCatalogOrganization = {
model: models.ResourceCatalog,
attributes: ['id', 'name'],
include: [{
model: models.Organization,
attributes: ['id', 'name'],
}]
}
const findObj = { const findObj = {
include: [ include: [
{ {
@ -22,7 +30,9 @@ function searchMeta(opts) {
include: [{ include: [{
model: models.Tag, model: models.Tag,
}] }]
}], },
resourceCatalogOrganization
],
where: { where: {
...where, ...where,
type: { $in: ['表', '库'] } type: { $in: ['表', '库'] }
@ -35,7 +45,9 @@ function searchMeta(opts) {
include: [{ include: [{
model: models.Tag, model: models.Tag,
}] }]
}], },
resourceCatalogOrganization
],
where: where where: where
} }
const findObj3 = { const findObj3 = {
@ -45,7 +57,8 @@ function searchMeta(opts) {
include: [{ include: [{
model: models.Tag, model: models.Tag,
}] }]
}], },
],
where: where where: where
} }

1
api/app/lib/index.js

@ -110,6 +110,7 @@ module.exports.models = function (dc) {
MetadataDatabase.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); MetadataDatabase.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' });
RestfulApi.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' }); ResourceCatalog.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' });
}; };

16
web/client/src/sections/resourceRetrieval/containers/retrieval.js

@ -201,15 +201,19 @@ function Retrieval(props) {
</div> </div>
<div className='column2'>相关操作<a onClick={() => { window.open(`/metadataManagement/latestMetadata?type=${METADTA_TYPE[s.type]}&treeId=${s?.catalog}&resourceId=${s.id}&catalogKey=${s.catalogKey}`) }}>定位</a> <div className='column2'>相关操作<a onClick={() => { window.open(`/metadataManagement/latestMetadata?type=${METADTA_TYPE[s.type]}&treeId=${s?.catalog}&resourceId=${s.id}&catalogKey=${s.catalogKey}`) }}>定位</a>
{s?.type == '表' || s?.type == '文件' ? {s?.type == '表' || s?.type == '文件' ?
user?.role == '数据消费者' ? user?.username !== 'SuperAmin' ?
<a onClick={() => { <a onClick={() => {
const token = approveList?.rows?.find(x => x.resourceId == s.id)?.token const isOrgAdmin = user?.role == '系统管理员' && user?.orgId == s?.resourceCatalog?.organization?.id
if (!token) { if (isOrgAdmin) {
message.warning('您暂未申请该数据资源,请先申请该数据资源') downloadData(s)
} else { } else {
setCurrentData(s) const token = approveList?.rows?.find(x => x.resourceId == s.id)?.token
if (!token) {
message.warning('您暂未申请该数据资源,请先申请该数据资源')
} else {
setCurrentData(s)
}
} }
}}>下载</a> : }}>下载</a> :
<a onClick={() => { downloadData(s) }}>下载</a> : ''} <a onClick={() => { downloadData(s) }}>下载</a> : ''}
</div> </div>

Loading…
Cancel
Save