micro_service/services/query.service.js

27 lines
768 B
JavaScript
Raw Normal View History

2021-01-21 10:36:09 +08:00
module.exports = {
name: 'query',
dependencies: ["conf", "db"],
actions: {
"exec": {
cache: false,
params: {
"key": {
"type": "string",
"optional": false,
"convert": true
},
"params": {
"type": "object",
"optional": true,
"convert": true
}
},
async handler(ctx) {
let key = ctx.params.key;
let sql = await this.broker.call("conf.get", {path: "sqls", key: key});
return this.broker.call("db.exec", {...sql, params: ctx.params.params});
}
}
}
};