1
This commit is contained in:
parent
eaeb7e2906
commit
8a1410c25c
@ -4,42 +4,28 @@ const utils = require('j7/utils');
|
||||
const http = require('j7/http');
|
||||
const serviceFactory = require('../services/factory');
|
||||
|
||||
/*
|
||||
data:
|
||||
{
|
||||
"seq_id": "",
|
||||
"target_url": "",
|
||||
"params"":[
|
||||
["xx", "xx"]
|
||||
],
|
||||
"cb_url": ""
|
||||
}
|
||||
*/
|
||||
async function get(session) {
|
||||
console.log('1111');
|
||||
const data = utils.jsonDecode(session.request('data', ''));
|
||||
const seqId = data['seq_id'];
|
||||
const targetUrl = data['target_url'];
|
||||
const cbUrl = data['cb_url'];
|
||||
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 {err, response} = await http.get(targetUrl, data['params']);
|
||||
console.log('response:' + response);
|
||||
if (err) {
|
||||
await http.get(cb,
|
||||
{
|
||||
'errcode': 1,
|
||||
'errmsg': '' + err,
|
||||
'data': utils.jsonEncode(data),
|
||||
});
|
||||
} else {
|
||||
await http.get(cb,
|
||||
{
|
||||
const params = utils.jsonDecode(session.request('params'));
|
||||
const {err, data} = await http.get(targetUrl, params);
|
||||
const rspJson = {
|
||||
'errcode': 0,
|
||||
'errmsg': '',
|
||||
'data': utils.jsonEncode(data),
|
||||
'response': response
|
||||
});
|
||||
'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();
|
||||
};
|
||||
|
@ -41,6 +41,10 @@ class Session {
|
||||
return name in this.req.query ? this.req.query[name] : defVal;
|
||||
}
|
||||
|
||||
requestToJson() {
|
||||
return utils.jsonEncode(this.req.query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Session;
|
||||
|
2
third_party/j7
vendored
2
third_party/j7
vendored
@ -1 +1 @@
|
||||
Subproject commit 870ed0107a6774f8a3f8fa7bbb9dcabb00bfae6d
|
||||
Subproject commit b48d506996787f8ecd00b3dfded4df10b41ddd88
|
Loading…
x
Reference in New Issue
Block a user