Browse Source

暂交库表元数据新建接口,修改元数据表模型

master
zmh 2 years ago
parent
commit
528232e9d1
  1. 40
      api/app/lib/controllers/latestMetadata/index.js
  2. 8
      api/app/lib/controllers/tags/index.js
  3. 9
      api/app/lib/models/metadata_database.js
  4. 9
      api/app/lib/models/metadata_file.js
  5. 9
      api/app/lib/models/metadata_restapi.js
  6. 11
      api/app/lib/routes/latestMetadata/index.js

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

@ -1,4 +1,7 @@
'use strict';
const moment = require("moment/moment");
//获取资源目录
async function getResourceCatalog(ctx) {
try {
@ -16,7 +19,7 @@ async function getResourceCatalog(ctx) {
}
}
}
//新资源目录
//新资源目录
async function postResourceCatalog(ctx) {
try {
const { name, code } = ctx.request.body;
@ -29,14 +32,14 @@ async function postResourceCatalog(ctx) {
ctx.body = { message: '该资源目录名称或代码已存在' }
} else {
await models.ResourceCatalog.create(ctx.request.body);
ctx.body = { message: '添加资源目录成功' }
ctx.body = { message: '新建资源目录成功' }
ctx.status = 200;
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "添加资源目录失败"
"message": "新建资源目录失败"
}
}
}
@ -249,6 +252,32 @@ async function getMetadataModels(ctx) {
}
}
}
//新建库表元数据
async function postMeatadataDatabases(ctx) {
try {
const { name, code, catalog } = ctx.request.body;
const models = ctx.fs.dc.models;
const postOne = await models.MetadataDatabase.findOne({
where: { $or: [{ name: name }, { code: code, catalog: catalog }] }
});
if (postOne) {
ctx.status = 400;
ctx.body = { message: '该资源目录下库表元数据名称或代码已存在' }
} else {
await models.MetadataDatabase.create({ createAt: moment(), ...ctx.request.body });
ctx.body = { message: '新建库表元数据成功' }
ctx.status = 200;
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "新建库表元数据失败"
}
}
}
module.exports = {
getResourceCatalog,
postResourceCatalog,
@ -257,5 +286,8 @@ module.exports = {
getMetadataDatabases,
getMetadataFiles,
getMetadataRestapis,
getMetadataModels
getMetadataModels,
postMeatadataDatabases,
// putMeatadataDatabases,
// delMeatadataDatabases
}

8
api/app/lib/controllers/tags/index.js

@ -31,14 +31,14 @@ async function postTagSets(ctx) {
ctx.body = { message: '该标签集名称已存在' }
} else {
await models.TagSet.create({ name });
ctx.body = { message: '添加标签集成功' }
ctx.body = { message: '新建标签集成功' }
ctx.status = 200;
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "添加标签集失败"
"message": "新建标签集失败"
}
}
}
@ -127,14 +127,14 @@ async function postTags(ctx) {
ctx.body = { message: '该标签名称已存在' }
} else {
await models.Tag.create({ name: name, tagSet: tagSetId });
ctx.body = { message: '添加标签成功' }
ctx.body = { message: '新建标签成功' }
ctx.status = 200;
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "添加标签失败"
"message": "新建标签失败"
}
}
}

9
api/app/lib/models/metadata_database.js

@ -113,6 +113,15 @@ module.exports = dc => {
primaryKey: false,
field: "update_at",
autoIncrement: false
},
catalogKey: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "catalogKey",
autoIncrement: false
}
}, {
tableName: "t_metadata_database",

9
api/app/lib/models/metadata_file.js

@ -104,6 +104,15 @@ module.exports = dc => {
primaryKey: false,
field: "update_at",
autoIncrement: false
},
catalogKey: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "catalogKey",
autoIncrement: false
}
}, {
tableName: "t_metadata_file",

9
api/app/lib/models/metadata_restapi.js

@ -131,6 +131,15 @@ module.exports = dc => {
primaryKey: false,
field: "update_at",
autoIncrement: false
},
catalogKey: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "catalogKey",
autoIncrement: false
}
}, {
tableName: "t_metadata_restapi",

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

@ -6,7 +6,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/resource-catalog'] = { content: '获取资源目录', visible: false };
router.get('/resource-catalog', latestMetadata.getResourceCatalog);
app.fs.api.logAttr['POST /resource-catalog'] = { content: '新资源目录', visible: true };
app.fs.api.logAttr['POST /resource-catalog'] = { content: '新资源目录', visible: true };
router.post('/resource-catalog', latestMetadata.postResourceCatalog);
app.fs.api.logAttr['PUT /resource-catalog/:id'] = { content: '修改资源目录', visible: true };
@ -26,4 +26,13 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/metadata/models'] = { content: '获取元数据模型', visible: false };
router.get('/metadata/models', latestMetadata.getMetadataModels);
app.fs.api.logAttr['POST /meatadata/databases'] = { content: '新建库表元数据', visible: true };
router.post('/meatadata/databases', latestMetadata.postMeatadataDatabases);
// app.fs.api.logAttr['PUT /meatadata/databases/:id'] = { content: '修改库表元数据', visible: true };
// router.put('/meatadata/databases/:id', latestMetadata.putMeatadataDatabases);
// app.fs.api.logAttr['DEL /meatadata/databases/:id'] = { content: '删除库表元数据', visible: true };
// router.delete('/meatadata/databases/:id', latestMetadata.delMeatadataDatabases);
};
Loading…
Cancel
Save