@hzab/data-model
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,6 @@ | ||
# @hzab/data-model@1.0.1 | ||
- fix: 修复 delete 入参问题 | ||
- fix: getApiUrl :xx 参数替换正则处理 | ||
# @hzab/data-model@0.2.3 | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "@hzab/data-model", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "data model", | ||
@@ -5,0 +5,0 @@ "main": "src", |
@@ -82,3 +82,3 @@ import _ from "lodash"; | ||
if (!_.isString(value) || !_.isNumber(value) || _.isBoolean(value)) { | ||
apiUrl = apiUrl.replace(`:${key}`, value); | ||
apiUrl = apiUrl.replace(new RegExp(`:${key}$|:${key}(?=\/)`), value); | ||
} | ||
@@ -223,11 +223,23 @@ }); | ||
delete(params, ctx) { | ||
let _params = _.cloneDeep(params); | ||
/** | ||
* 删除接口 | ||
* @param {*} config axios.delete config 参数, | ||
* @param {*} config.params axios.delete url 参数, | ||
* @param {*} config.data axios.delete data 参数, | ||
* @param {*} ctx | ||
* @returns | ||
*/ | ||
delete(config, ctx) { | ||
let _config = _.cloneDeep(config) || {}; | ||
if (this.deleteReqMap) { | ||
_params = this.deleteReqMap(_params); | ||
_config = this.deleteReqMap(_config); | ||
} | ||
return new Promise((resolve, reject) => { | ||
const apiUrl = this.getApiUrl(this.deleteApi, _params, ctx); | ||
const apiUrl = this.getApiUrl( | ||
this.deleteApi, | ||
Object.assign(_.cloneDeep(_config), _config.params, _config.data), | ||
ctx, | ||
); | ||
this.axios | ||
.delete(apiUrl, { ...this.axiosConf, params: _params }) | ||
.delete(apiUrl, { ...this.axiosConf, ..._config }) | ||
.then((response) => { | ||
@@ -249,11 +261,23 @@ this.handleRes( | ||
multipleDelete(params, ctx) { | ||
let _params = _.cloneDeep(params); | ||
/** | ||
* 批量删除接口 | ||
* @param {*} config axios.delete config 参数, | ||
* @param {*} config.params axios.delete url 参数, | ||
* @param {*} config.data axios.delete data 参数, | ||
* @param {*} ctx | ||
* @returns | ||
*/ | ||
multipleDelete(config, ctx) { | ||
let _config = _.cloneDeep(config) || {}; | ||
if (this.multipleDeleteReqMap) { | ||
_params = this.multipleDeleteReqMap(_params); | ||
_config = this.multipleDeleteReqMap(_config); | ||
} | ||
return new Promise((resolve, reject) => { | ||
const apiUrl = this.getApiUrl(this.multipleDeleteApi, _params, ctx); | ||
const apiUrl = this.getApiUrl( | ||
this.multipleDeleteApi, | ||
Object.assign(_.cloneDeep(_config), _config.params, _config.data), | ||
ctx, | ||
); | ||
this.axios | ||
.delete(apiUrl, { ...this.axiosConf, params: _params }) | ||
.delete(apiUrl, { ...this.axiosConf, ..._config }) | ||
.then((response) => { | ||
@@ -260,0 +284,0 @@ this.handleRes( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22178
479