政务数据资源中心(Government data Resource center)
03专项3期主要建设内容
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// 新增数据源
|
|
|
|
function addDataSource(opts) {
|
|
|
|
return async function (ctx, next) {
|
|
|
|
|
|
|
|
const models = ctx.fs.dc.models;
|
|
|
|
try {
|
|
|
|
let rslt = ctx.request.body;
|
|
|
|
await models.DataSource.create(Object.assign({}, rslt))
|
|
|
|
ctx.status = 204;
|
|
|
|
ctx.body = { message: '新建数据源成功' }
|
|
|
|
} catch (error) {
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
|
|
ctx.status = 400;
|
|
|
|
ctx.body = { message: '新建数据源失败' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDataSource(opts) {
|
|
|
|
return async function (ctx, next) {
|
|
|
|
const models = ctx.fs.dc.models;
|
|
|
|
let errMsg = { message: '获取数据源失败' }
|
|
|
|
try {
|
|
|
|
let option = {
|
|
|
|
where: {},
|
|
|
|
order: [["id", "desc"]],
|
|
|
|
}
|
|
|
|
|
|
|
|
const res = await models.DataSource.findAll(option);
|
|
|
|
ctx.status = 200;
|
|
|
|
ctx.body = res;
|
|
|
|
} catch (error) {
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
|
|
ctx.status = 400;
|
|
|
|
ctx.body = errMsg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
addDataSource,
|
|
|
|
getDataSource
|
|
|
|
}
|