|
|
@ -1,5 +1,5 @@ |
|
|
|
'use strict'; |
|
|
|
//获取资源目录列表
|
|
|
|
//获取资源目录
|
|
|
|
async function getResourceCatalog(ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
@ -107,9 +107,123 @@ async function delResourceCatalog(ctx) { |
|
|
|
ctx.body = { message: '删除资源目录失败' } |
|
|
|
} |
|
|
|
} |
|
|
|
//获取库表元数据列表
|
|
|
|
async function getMetadataDatabases(ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc' } = ctx.query; |
|
|
|
const where = { catalog: catalog }; |
|
|
|
if (keywords) { |
|
|
|
where[$or] = [{ name: { $like: keywords } }, { code: { $like: keywords } }, { type: { $like: keywords } }] |
|
|
|
} |
|
|
|
const rslt = await models.MetadataDatabase.findAll({ |
|
|
|
include: [ |
|
|
|
{ |
|
|
|
model: models.User, |
|
|
|
attributes: ['id', 'name'], |
|
|
|
}, |
|
|
|
{ |
|
|
|
model: models.TagDatabase, |
|
|
|
include: [{ |
|
|
|
model: models.Tag, |
|
|
|
}] |
|
|
|
}], |
|
|
|
where: where, |
|
|
|
order: [[orderBy, orderDirection]], |
|
|
|
offset: Number(offset) * Number(limit), |
|
|
|
limit: Number(limit), |
|
|
|
distinct: true |
|
|
|
}); |
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = rslt; |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
"message": "获取库表元数据列表失败" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//获取文件元数据列表
|
|
|
|
async function getMetadataFiles(ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc' } = ctx.query; |
|
|
|
const where = { catalog: catalog }; |
|
|
|
if (keywords) { |
|
|
|
where[$or] = [{ name: { $like: keywords } }, { type: { $like: keywords } }] |
|
|
|
} |
|
|
|
const rslt = await models.MetadataFile.findAll({ |
|
|
|
include: [ |
|
|
|
{ |
|
|
|
model: models.User, |
|
|
|
attributes: ['id', 'name'], |
|
|
|
}, |
|
|
|
{ |
|
|
|
model: models.TagFile, |
|
|
|
include: [{ |
|
|
|
model: models.Tag, |
|
|
|
}] |
|
|
|
}], |
|
|
|
where: where, |
|
|
|
order: [[orderBy, orderDirection]], |
|
|
|
offset: Number(offset) * Number(limit), |
|
|
|
limit: Number(limit), |
|
|
|
distinct: true |
|
|
|
}); |
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = rslt; |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
"message": "获取文件元数据列表失败" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//获取接口元数据列表
|
|
|
|
async function getMetadataRestapis(ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc' } = ctx.query; |
|
|
|
const where = { catalog: catalog }; |
|
|
|
if (keywords) { |
|
|
|
where.name = { $like: keywords }; |
|
|
|
} |
|
|
|
const rslt = await models.MetadataRestapi.findAll({ |
|
|
|
include: [ |
|
|
|
{ |
|
|
|
model: models.User, |
|
|
|
attributes: ['id', 'name'], |
|
|
|
}, |
|
|
|
{ |
|
|
|
model: models.TagRestapi, |
|
|
|
include: [{ |
|
|
|
model: models.Tag, |
|
|
|
}] |
|
|
|
}], |
|
|
|
where: where, |
|
|
|
order: [[orderBy, orderDirection]], |
|
|
|
offset: Number(offset) * Number(limit), |
|
|
|
limit: Number(limit), |
|
|
|
distinct: true |
|
|
|
}); |
|
|
|
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 = { |
|
|
|
getResourceCatalog, |
|
|
|
postResourceCatalog, |
|
|
|
putResourceCatalog, |
|
|
|
delResourceCatalog |
|
|
|
delResourceCatalog, |
|
|
|
getMetadataDatabases, |
|
|
|
getMetadataFiles, |
|
|
|
getMetadataRestapis |
|
|
|
} |