Files
SOP/sop-sdk/sdk-nodejs/request/BaseRequest.js
tanghc 160e57df0e 4.0.2
2020-08-10 17:18:20 +08:00

49 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {Class} = require("../common/Class");
/**
* 请求类父类
*/
exports.BaseRequest = Class.create({
init: function(){
this.bizModel = {}
/*
[
{name: 'file1', path: 'd:/dd/1.txt'},
{name: 'file2', path: 'd:/dd/2.txt'}
]
*/
this.files = []
},
/**
* 返回接口名称
*/
getMethod: function() {
throw `未实现BaseRequest类getMethod()方法`;
},
/**
* 返回版本号
*/
getVersion: function() {
throw '未实现BaseRequest类getVersion()方法';
},
/**
* 返回请求类型使用RequestType.js
*/
getRequestType: function() {
throw '未实现BaseRequest类getRequestType()方法';
},
/**
* 解析返回结果,子类可以覆盖实现
* @param responseData 服务器返回内容
* @returns 返回结果
*/
parseResponse: function (responseData) {
let data = responseData['error_response'];
if (!data) {
const dataNodeName = this.getMethod().replace(/\./g, '_') + '_response'
data = responseData[dataNodeName]
}
return data;
}
})