This commit is contained in:
azw 2024-04-03 08:29:13 +00:00
parent 9d85f1b22c
commit efde54bef1
4 changed files with 38 additions and 1 deletions

View File

@ -68,6 +68,31 @@ async function get(session) {
}; };
async function post(session) { async function post(session) {
console.log('post data', session.getBody());
const postData = session.getBody();
const seqId = session.request('seq_id');
const targetUrl = session.request('target_url');
const cbUrl = session.request('cb_url');
const reqJson = session.requestToJson();
new Promise(async (resolve) => {
const params = utils.jsonDecode(session.request('params'));
const {err, data} = await http.post(targetUrl, params, postData);
const rspJson = {
'errcode': 0,
'errmsg': '',
'seq_id': seqId,
'req_json': reqJson,
'data': data
};
if (err) {
rspJson['errcode'] = 1;
rspJson['errmsg'] = '' + err;
}
console.log('data', data);
console.log('rspJson:' + utils.jsonEncode(rspJson));
await http.get(cbUrl, rspJson);
});
session.rspOk();
} }
function init() { function init() {

View File

@ -15,10 +15,14 @@
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"axios": "^0.26.1", "axios": "^0.26.1",
"body-parser": "^1.20.0",
"crc-32": "^1.2.1", "crc-32": "^1.2.1",
"express": "^4.17.2", "express": "^4.17.2",
"minimist": "^1.2.6",
"mysql": "~2.18.1", "mysql": "~2.18.1",
"node-xlsx": "^0.21.0",
"querystring": "^0.2.1", "querystring": "^0.2.1",
"redis": "^4.1.0",
"urlencode": "^1.1.0" "urlencode": "^1.1.0"
} }
}, },
@ -32,10 +36,14 @@
"version": "file:../../third_party/j7", "version": "file:../../third_party/j7",
"requires": { "requires": {
"axios": "^0.26.1", "axios": "^0.26.1",
"body-parser": "^1.20.0",
"crc-32": "^1.2.1", "crc-32": "^1.2.1",
"express": "^4.17.2", "express": "^4.17.2",
"minimist": "^1.2.6",
"mysql": "~2.18.1", "mysql": "~2.18.1",
"node-xlsx": "^0.21.0",
"querystring": "^0.2.1", "querystring": "^0.2.1",
"redis": "^4.1.0",
"urlencode": "^1.1.0" "urlencode": "^1.1.0"
} }
} }

View File

@ -49,6 +49,10 @@ class Session {
return utils.jsonEncode(this.req.query); return utils.jsonEncode(this.req.query);
} }
getBody() {
return this.req.body;
}
} }
module.exports = Session; module.exports = Session;

2
third_party/j7 vendored

@ -1 +1 @@
Subproject commit f81baf8c264c00395b4dd27f900df6ffedceac08 Subproject commit e3b86e927f2cbccc97a024bed1573c5ca24cbfde