|
|
@ -3,7 +3,7 @@ const moment = require('moment') |
|
|
|
|
|
|
|
|
|
|
|
//获取REST服务失败
|
|
|
|
function getServiceManagement (opts) { |
|
|
|
function getServiceManagement(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
@ -44,7 +44,7 @@ function getServiceManagement (opts) { |
|
|
|
} |
|
|
|
|
|
|
|
//编辑REST服务
|
|
|
|
function postServiceManagement (opts) { |
|
|
|
function postServiceManagement(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
|
|
|
|
try { |
|
|
@ -63,7 +63,7 @@ function postServiceManagement (opts) { |
|
|
|
} |
|
|
|
|
|
|
|
//编辑REST服务
|
|
|
|
function delServiceManagement (opts) { |
|
|
|
function delServiceManagement(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
@ -86,7 +86,7 @@ function delServiceManagement (opts) { |
|
|
|
|
|
|
|
|
|
|
|
//获取表字段
|
|
|
|
function getLookField (opts) { |
|
|
|
function getLookField(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
@ -128,10 +128,49 @@ function getLookField (opts) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取rest服务申请次数
|
|
|
|
function getResourceConsumptionCount(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
let errMsg = { message: '获取接口资源申请次数失败' } |
|
|
|
try { |
|
|
|
const rslt = await models.ResourceConsumption.count({ |
|
|
|
attributes: [ |
|
|
|
'rest_service_id', // 分组的字段
|
|
|
|
], |
|
|
|
group: ['rest_service_id'], // 分组的字段
|
|
|
|
where: { |
|
|
|
resourceType: '数据服务' |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const rests = await models.RestfulApi.findAll() |
|
|
|
let arr = [] |
|
|
|
rslt.map(s => { |
|
|
|
let rest = rests.find(x => x.id == s.rest_service_id) |
|
|
|
if (rest) { |
|
|
|
arr.push({ |
|
|
|
count: s.count, |
|
|
|
name: rest.name |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = arr; |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = errMsg |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
getServiceManagement, |
|
|
|
postServiceManagement, |
|
|
|
delServiceManagement, |
|
|
|
getLookField |
|
|
|
getLookField, |
|
|
|
getResourceConsumptionCount |
|
|
|
|
|
|
|
} |