@hzab/data-model
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -0,1 +1,5 @@ | ||
# @hzab/data-model@1.5.0 | ||
- feat: 增加 patch 请求方式函数 | ||
# @hzab/data-model@1.4.1 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "@hzab/data-model", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "data model", | ||
@@ -5,0 +5,0 @@ "main": "src", |
@@ -42,6 +42,10 @@ # @hzab/data-model | ||
getListFunc, | ||
// 编辑接口 put url | ||
// put 编辑接口 url | ||
updateApi, | ||
// 编辑接口 put 入参枚举函数 | ||
// put 编辑接口 入参枚举函数 | ||
updateMap, | ||
// patch 编辑接口 url | ||
patchApi, | ||
// patch 编辑接口 入参枚举函数 | ||
patchMap, | ||
// 删除接口 delete url | ||
@@ -65,2 +69,4 @@ deleteApi, | ||
updateAxiosConf, | ||
// patch 接口 axios 相关配置 | ||
patchAxiosConf, | ||
// delete 接口 axios 相关配置 | ||
@@ -86,2 +92,6 @@ deleteAxiosConf, | ||
updateResMap, | ||
// patch 编辑接口 put 入参枚举函数 | ||
patchReqMap, | ||
// patch 编辑接口 put 出参枚举函数 | ||
patchResMap, | ||
// 删除接口 delete 入参枚举函数 | ||
@@ -132,2 +142,3 @@ deleteReqMap, | ||
| updateApi | string | 否 | - | put 接口地址 | | ||
| patchApi | string | 否 | - | patch 接口地址 | | ||
| deleteApi | string | 否 | - | delete 接口地址 | | ||
@@ -140,2 +151,3 @@ | multipleDeleteApi | string | 否 | - | 批量删除 delete 接口地址 | | ||
| updateMap | Function | 否 | - | updateApi 接口提交前的处理函数 | | ||
| patchMap | Function | 否 | - | patchApi 接口提交前的处理函数 | | ||
| axios | Object | 否 | - | axios 实例对象 | | ||
@@ -147,2 +159,3 @@ | axiosConf | Object | 否 | - | axios 相关配置 | | ||
| updateAxiosConf | Object | 否 | - | update 接口 axios 相关配置 | | ||
| patchAxiosConf | Object | 否 | - | patch 接口 axios 相关配置 | | ||
| deleteAxiosConf | Object | 否 | - | delete 接口 axios 相关配置 | | ||
@@ -158,2 +171,4 @@ | multipleDeleteAxiosConf | Object | 否 | - | multipleDelete 接口 axios 相关配置 | | ||
| updateResMap | Function | 否 | - | 编辑接口 get 出参枚举函数 | | ||
| patchReqMap | Function | 否 | - | patch 接口 get 入参枚举函数 | | ||
| patchResMap | Function | 否 | - | patch 接口 get 出参枚举函数 | | ||
| deleteReqMap | Function | 否 | - | 删除接口 get 入参枚举函数 | | ||
@@ -160,0 +175,0 @@ | deleteResMap | Function | 否 | - | 删除接口 get 出参枚举函数 | |
@@ -28,2 +28,4 @@ import _ from "lodash"; | ||
updateMap, | ||
patchApi, | ||
patchMap, | ||
deleteApi, | ||
@@ -57,2 +59,4 @@ multipleDeleteApi, | ||
this.updateMap = updateMap; | ||
this.patchApi = patchApi; | ||
this.patchMap = patchMap; | ||
this.deleteApi = deleteApi; | ||
@@ -70,2 +74,4 @@ this.multipleDeleteApi = multipleDeleteApi; | ||
updateResMap, | ||
patchReqMap, | ||
patchResMap, | ||
deleteReqMap, | ||
@@ -84,2 +90,4 @@ deleteResMap, | ||
this.updateResMap = updateResMap; | ||
this.patchReqMap = patchReqMap; | ||
this.patchResMap = patchResMap; | ||
this.deleteReqMap = deleteReqMap; | ||
@@ -95,2 +103,3 @@ this.deleteResMap = deleteResMap; | ||
updateAxiosConf, | ||
patchAxiosConf, | ||
deleteAxiosConf, | ||
@@ -103,2 +112,3 @@ multipleDeleteAxiosConf, | ||
this.updateAxiosConf = updateAxiosConf; | ||
this.patchAxiosConf = patchAxiosConf; | ||
this.deleteAxiosConf = deleteAxiosConf; | ||
@@ -172,2 +182,5 @@ this.multipleDeleteAxiosConf = multipleDeleteAxiosConf; | ||
resultList = await this.getListFunc(query); | ||
if (this.getListResMap) { | ||
resultList = this.getListResMap(resultList); | ||
} | ||
} else { | ||
@@ -270,2 +283,32 @@ const getPro = new Promise((resolve, reject) => { | ||
patch(params, ctx, axiosConf) { | ||
return new Promise((resolve, reject) => { | ||
const opt = { ...this.axiosConf, ...this.patchAxiosConf, ...axiosConf }; | ||
let _params = _.cloneDeep(formDataToObj(params)); | ||
if (this.patchReqMap) { | ||
_params = this.patchReqMap(_params, params); | ||
} | ||
const apiUrl = this.getApiUrl(this.patchApi, _params, ctx, { from: "patch" }); | ||
if (params instanceof FormData) { | ||
opt.headers = { ...(opt.headers ?? {}), "Content-Type": "multipart/form-data" }; | ||
_params = objToFormData(_params); | ||
} | ||
this.axios | ||
.patch(apiUrl, _params, opt) | ||
.then((response) => { | ||
this.handleRes( | ||
response, | ||
(res) => { | ||
if (this.patchResMap) { | ||
res = this.patchResMap(res); | ||
} | ||
resolve(res); | ||
}, | ||
reject, | ||
); | ||
}) | ||
.catch((err) => this.errorHandler(err, reject)); | ||
}); | ||
} | ||
/** | ||
@@ -272,0 +315,0 @@ * 删除接口 |
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
31048
648
228