peng.peng 2 years ago
parent
commit
e3eaf9b835
  1. 43
      api/app/lib/controllers/latestMetadata/index.js
  2. 3
      api/app/lib/routes/latestMetadata/index.js

43
api/app/lib/controllers/latestMetadata/index.js

@ -114,8 +114,14 @@ async function delResourceCatalog(ctx) {
async function getMetadataDatabases(ctx) { async function getMetadataDatabases(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc' } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', id = null } = ctx.query;
const where = { catalog: catalog }; const where = {};
if (catalog) {
where.catalog = catalog;
}
if (id) {
where.parent = id;
}
if (keywords) { if (keywords) {
where['$or'] = [{ name: { $iLike: `%${keywords}%` } }, where['$or'] = [{ name: { $iLike: `%${keywords}%` } },
{ code: { $iLike: `%${keywords}%` } }, { code: { $iLike: `%${keywords}%` } },
@ -278,6 +284,36 @@ async function postMeatadataDatabases(ctx) {
} }
} }
//获取库表元数据基本信息
async function getMetadataDatabasesById(ctx) {
try {
const models = ctx.fs.dc.models;
const { id } = ctx.params;
const findObj = {
include: [
{
model: models.User,
attributes: ['id', 'name', 'username'],
},
{
model: models.TagDatabase,
include: [{
model: models.Tag,
}]
}],
where: { id: id },
}
const rslt = await models.MetadataDatabase.findOne(findObj);
ctx.status = 200;
ctx.body = rslt;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "获取库表元数据基本信息失败"
}
}
}
module.exports = { module.exports = {
getResourceCatalog, getResourceCatalog,
postResourceCatalog, postResourceCatalog,
@ -289,5 +325,6 @@ module.exports = {
getMetadataModels, getMetadataModels,
postMeatadataDatabases, postMeatadataDatabases,
// putMeatadataDatabases, // putMeatadataDatabases,
// delMeatadataDatabases // delMeatadataDatabases,
getMetadataDatabasesById
} }

3
api/app/lib/routes/latestMetadata/index.js

@ -35,4 +35,7 @@ module.exports = function (app, router, opts) {
// app.fs.api.logAttr['DEL /meatadata/databases/:id'] = { content: '删除库表元数据', visible: true }; // app.fs.api.logAttr['DEL /meatadata/databases/:id'] = { content: '删除库表元数据', visible: true };
// router.delete('/meatadata/databases/:id', latestMetadata.delMeatadataDatabases); // router.delete('/meatadata/databases/:id', latestMetadata.delMeatadataDatabases);
app.fs.api.logAttr['GET/metadata/databases/:id'] = { content: '获取库表元数据基本信息', visible: false };
router.get('/metadata/databases/:id', latestMetadata.getMetadataDatabasesById);
}; };
Loading…
Cancel
Save