From f09e00ddd7eee920fd07ad804fdd726f0eb5a895 Mon Sep 17 00:00:00 2001 From: Changeden Date: Wed, 14 Apr 2021 10:21:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84sdk-nodejs-axios=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{request => common}/BaseRequest.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) rename sop-sdk/sdk-nodejs-axios/{request => common}/BaseRequest.js (82%) diff --git a/sop-sdk/sdk-nodejs-axios/request/BaseRequest.js b/sop-sdk/sdk-nodejs-axios/common/BaseRequest.js similarity index 82% rename from sop-sdk/sdk-nodejs-axios/request/BaseRequest.js rename to sop-sdk/sdk-nodejs-axios/common/BaseRequest.js index a3b5b641..255f8870 100644 --- a/sop-sdk/sdk-nodejs-axios/request/BaseRequest.js +++ b/sop-sdk/sdk-nodejs-axios/common/BaseRequest.js @@ -2,7 +2,7 @@ const isArray = require('isarray'); /** * 请求类父类 */ -exports.BaseRequest = class BaseRequest { +module.exports = class BaseRequest { constructor() { this.bizModel = {}; @@ -10,6 +10,21 @@ exports.BaseRequest = class BaseRequest { // 用于文件上传时强制转换成POST_FILE请求 this.__forceRequestType__ = undefined; + + this.checkOverride(); + } + + /** + * 校验子类是否已重写相关方法 + * */ + checkOverride() { + try { + this.getMethod(); + this.getVersion(); + this.getRequestType(); + } catch (error) { + throw error; + } } setBizModel(biz = {}) { @@ -22,7 +37,7 @@ exports.BaseRequest = class BaseRequest { return this; } - addFile({name, path}) { + addFile(name, path) { if (name && path) { if (!isArray(this.files)) { this.files = []; @@ -75,4 +90,4 @@ exports.BaseRequest = class BaseRequest { } return data; } -}; \ No newline at end of file +};