Browse Source

(*)接口调整

master
peng.peng 2 years ago
parent
commit
b1a0c65c29
  1. 77
      api/app/lib/controllers/latestMetadata/index.js

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

@ -3,7 +3,7 @@
const moment = require("moment/moment"); const moment = require("moment/moment");
//获取资源目录 //获取资源目录
async function getResourceCatalog (ctx) { async function getResourceCatalog(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const rslt = await models.ResourceCatalog.findAll({ const rslt = await models.ResourceCatalog.findAll({
@ -20,7 +20,7 @@ async function getResourceCatalog (ctx) {
} }
} }
//新建资源目录 //新建资源目录
async function postResourceCatalog (ctx) { async function postResourceCatalog(ctx) {
try { try {
const { name, code } = ctx.request.body; const { name, code } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -49,7 +49,7 @@ async function postResourceCatalog (ctx) {
} }
} }
//修改资源目录 //修改资源目录
async function putResourceCatalog (ctx) { async function putResourceCatalog(ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { name, code, description } = ctx.request.body; const { name, code, description } = ctx.request.body;
@ -78,7 +78,7 @@ async function putResourceCatalog (ctx) {
} }
} }
//删除资源目录 //删除资源目录
async function delResourceCatalog (ctx) { async function delResourceCatalog(ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -117,7 +117,7 @@ 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', id = null, resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', id = null, resourceId } = ctx.query;
@ -169,7 +169,7 @@ async function getMetadataDatabases (ctx) {
} }
} }
//获取文件元数据列表 //获取文件元数据列表
async function getMetadataFiles (ctx) { async function getMetadataFiles(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'updateAt', orderDirection = 'desc', resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'updateAt', orderDirection = 'desc', resourceId } = ctx.query;
@ -214,7 +214,7 @@ async function getMetadataFiles (ctx) {
} }
} }
//获取接口元数据列表 //获取接口元数据列表
async function getMetadataRestapis (ctx) { async function getMetadataRestapis(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', resourceId } = ctx.query;
@ -257,7 +257,7 @@ async function getMetadataRestapis (ctx) {
} }
} }
//获取元数据模型 //获取元数据模型
async function getMetadataModels (ctx) { async function getMetadataModels(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { modelTypes } = ctx.query; const { modelTypes } = ctx.query;
@ -281,7 +281,7 @@ async function getMetadataModels (ctx) {
} }
//新建库表元数据 //新建库表元数据
async function postMetadataDatabases (ctx) { async function postMetadataDatabases(ctx) {
try { try {
const { name, code, catalog, parent } = ctx.request.body; const { name, code, catalog, parent } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -318,7 +318,7 @@ async function postMetadataDatabases (ctx) {
} }
//修改库表元数据 //修改库表元数据
async function putMetadataDatabases (ctx) { async function putMetadataDatabases(ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { catalog, name, code } = ctx.request.body; const { catalog, name, code } = ctx.request.body;
@ -354,7 +354,7 @@ async function putMetadataDatabases (ctx) {
} }
} }
//删除库表元数据 //删除库表元数据
async function delMetadataDatabases (ctx) { async function delMetadataDatabases(ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -409,7 +409,7 @@ async function delMetadataDatabases (ctx) {
} }
} }
//获取库表元数据基本信息 //获取库表元数据基本信息
async function getMetadataDatabasesById (ctx) { async function getMetadataDatabasesById(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -440,7 +440,7 @@ async function getMetadataDatabasesById (ctx) {
} }
//打标元数据 //打标元数据
async function postTagMetadata (ctx) { async function postTagMetadata(ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const { tags, database, file, restapi } = ctx.request.body; const { tags, database, file, restapi } = ctx.request.body;
@ -481,7 +481,7 @@ async function postTagMetadata (ctx) {
} }
//获取元数据已打标数据 //获取元数据已打标数据
async function getTagMetadata (ctx) { async function getTagMetadata(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -525,7 +525,7 @@ async function getTagMetadata (ctx) {
} }
} }
//申请资源 //申请资源
async function postMetadataResourceApplications (ctx) { async function postMetadataResourceApplications(ctx) {
try { try {
const { resourceName, applyBy, resourceType, resourceId } = ctx.request.body; const { resourceName, applyBy, resourceType, resourceId } = ctx.request.body;
if (!resourceName || !applyBy || !resourceType || !resourceId) { if (!resourceName || !applyBy || !resourceType || !resourceId) {
@ -539,31 +539,32 @@ async function postMetadataResourceApplications (ctx) {
if (postOne) { if (postOne) {
ctx.status = 400; ctx.status = 400;
ctx.body = { message: '参数不全,请重新申请资源' } ctx.body = { message: '参数不全,请重新申请资源' }
} else { } else {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const postOne = await models.ResourceConsumption.findOne({ const postOne = await models.ResourceConsumption.findOne({
where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType, approve_remarks: null } where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType, approve_remarks: null }
}); });
if (postOne) { if (postOne) {
ctx.status = 400; ctx.status = 400;
ctx.body = { message: '该用户已申请过该元数据资源' } ctx.body = { message: '该用户已申请过该元数据资源' }
} else { } else {
await models.ResourceConsumption.create({ applyAt: moment(), approveState: '审批中', ...ctx.request.body }); await models.ResourceConsumption.create({ applyAt: moment(), approveState: '审批中', ...ctx.request.body });
ctx.body = { message: '申请资源成功' } ctx.body = { message: '申请资源成功' }
ctx.status = 200; ctx.status = 200;
} }
} }
} catch (error) { }
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); } catch (error) {
ctx.status = 400; ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.body = { ctx.status = 400;
"message": "申请资源失败" ctx.body = {
} "message": "申请资源失败"
} }
}
} }
//获取元数据资源申请记录 //获取元数据资源申请记录
async function getMetadataResourceApplications (ctx) { async function getMetadataResourceApplications(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { resourceNames, type } = ctx.query; const { resourceNames, type } = ctx.query;
@ -585,7 +586,7 @@ async function getMetadataResourceApplications (ctx) {
} }
//新建文件元数据 //新建文件元数据
async function postMetadataFiles (ctx) { async function postMetadataFiles(ctx) {
try { try {
const { name, catalog, type, fileName } = ctx.request.body; const { name, catalog, type, fileName } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -614,7 +615,7 @@ async function postMetadataFiles (ctx) {
} }
} }
//修改文件元数据 //修改文件元数据
async function putMetadataFiles (ctx) { async function putMetadataFiles(ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { updateFileName } = ctx.query; const { updateFileName } = ctx.query;
@ -654,7 +655,7 @@ async function putMetadataFiles (ctx) {
} }
} }
//删除文件元数据 //删除文件元数据
async function delMetadataFiles (ctx) { async function delMetadataFiles(ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -702,7 +703,7 @@ async function delMetadataFiles (ctx) {
} }
//新建接口元数据 //新建接口元数据
async function postMetadataRestapis (ctx) { async function postMetadataRestapis(ctx) {
try { try {
const { name, catalog, method, url } = ctx.request.body; const { name, catalog, method, url } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -732,7 +733,7 @@ async function postMetadataRestapis (ctx) {
} }
//修改接口元数据 //修改接口元数据
async function putMetadataRestapis (ctx) { async function putMetadataRestapis(ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { catalog, name, method, url } = ctx.request.body; const { catalog, name, method, url } = ctx.request.body;
@ -766,7 +767,7 @@ async function putMetadataRestapis (ctx) {
} }
} }
//删除接口元数据 //删除接口元数据
async function delMetadataRestapis (ctx) { async function delMetadataRestapis(ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -814,7 +815,7 @@ async function delMetadataRestapis (ctx) {
} }
//获取对表的库与字段信息 //获取对表的库与字段信息
async function listStructuredData (ctx) { async function listStructuredData(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id, parent } = ctx.query; const { id, parent } = ctx.query;

Loading…
Cancel
Save