This commit is contained in:
aozhiwei 2022-03-31 21:55:40 +08:00
parent eaeb7e2906
commit 8a1410c25c
3 changed files with 23 additions and 33 deletions

View File

@ -4,42 +4,28 @@ const utils = require('j7/utils');
const http = require('j7/http'); const http = require('j7/http');
const serviceFactory = require('../services/factory'); const serviceFactory = require('../services/factory');
/*
data:
{
"seq_id": "",
"target_url": "",
"params"":[
["xx", "xx"]
],
"cb_url": ""
}
*/
async function get(session) { async function get(session) {
console.log('1111'); const seqId = session.request('seq_id');
const data = utils.jsonDecode(session.request('data', '')); const targetUrl = session.request('target_url');
const seqId = data['seq_id']; const cbUrl = session.request('cb_url');
const targetUrl = data['target_url']; const reqJson = session.requestToJson();
const cbUrl = data['cb_url'];
new Promise(async (resolve) => { new Promise(async (resolve) => {
const {err, response} = await http.get(targetUrl, data['params']); const params = utils.jsonDecode(session.request('params'));
console.log('response:' + response); const {err, data} = await http.get(targetUrl, params);
const rspJson = {
'errcode': 0,
'errmsg': '',
'seq_id': seqId,
'req_json': reqJson,
'data': data
};
if (err) { if (err) {
await http.get(cb, rspJson['errcode'] = 1;
{ rspJson['errmsg'] = '' + err;
'errcode': 1,
'errmsg': '' + err,
'data': utils.jsonEncode(data),
});
} else {
await http.get(cb,
{
'errcode': 0,
'errmsg': '',
'data': utils.jsonEncode(data),
'response': response
});
} }
console.log('data', data);
console.log('rspJson:' + utils.jsonEncode(rspJson));
await http.get(cbUrl, rspJson);
}); });
session.rspOk(); session.rspOk();
}; };

View File

@ -41,6 +41,10 @@ class Session {
return name in this.req.query ? this.req.query[name] : defVal; return name in this.req.query ? this.req.query[name] : defVal;
} }
requestToJson() {
return utils.jsonEncode(this.req.query);
}
} }
module.exports = Session; module.exports = Session;

2
third_party/j7 vendored

@ -1 +1 @@
Subproject commit 870ed0107a6774f8a3f8fa7bbb9dcabb00bfae6d Subproject commit b48d506996787f8ecd00b3dfded4df10b41ddd88