Commit cdd4fabc by 庄冰

push2ali

parent 789fc825
const Client = require('aliyun-api-gateway').Client;
var RPCClient = require('@alicloud/pop-core').RPCClient;
const system = require("../system");
class aliyunClient {
constructor() {
this.aliclient = new RPCClient({
......@@ -9,6 +9,7 @@ class aliyunClient {
endpoint: "https://companyreg.aliyuncs.com",
apiVersion: "2020-03-06"
});
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
async post(aliReqUrl, key, secret, actionBody) {
const client = new Client(key, secret);
......@@ -28,13 +29,35 @@ class aliyunClient {
async reqbyget(obj, cbk) {
var action = obj.action;
var reqbody = obj.reqbody;
return this.aliclient.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
try {
var res = await this.aliclient.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
this.pushlogSve.createDb({
op: "推送阿里信息返回:" + action,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(res),
returnType: '1',
logLevel:'1',
opTitle: "推送阿里信息返回成功"
});
return system.getResultSuccess(res);
} catch (e) {
this.pushlogSve.createDb({
op: "推送阿里信息返回:" + action,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
returnType: '0',
logLevel:'3',
opTitle: "推送阿里信息返回异常"
});
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment