feat(apis): add PATCH request related API functions
新增了通用PATCH请求API以及管理员、超管理员权限的PATCH请求封装函数,完善API请求方法覆盖范围
This commit is contained in:
parent
825a5e9769
commit
02e4b92927
@ -225,6 +225,38 @@ export function apiSuperAdminPut(url, data = {}, options = {}, responseType = 'j
|
|||||||
return apiPut(url, data, options, true, responseType)
|
return apiPut(url, data, options, true, responseType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送PATCH请求
|
||||||
|
* @param {string} url - API端点
|
||||||
|
* @param {Object} data - 请求体数据
|
||||||
|
* @param {Object} options - 其他请求选项
|
||||||
|
* @param {boolean} requiresAuth - 是否需要认证
|
||||||
|
* @param {string} responseType - 响应类型: 'json' | 'text' | 'blob'
|
||||||
|
* @returns {Promise} - 请求结果
|
||||||
|
*/
|
||||||
|
export function apiPatch(url, data = {}, options = {}, requiresAuth = true, responseType = 'json') {
|
||||||
|
return apiRequest(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
method: 'PATCH',
|
||||||
|
body: data instanceof FormData ? data : JSON.stringify(data),
|
||||||
|
...options
|
||||||
|
},
|
||||||
|
requiresAuth,
|
||||||
|
responseType
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function apiAdminPatch(url, data = {}, options = {}, responseType = 'json') {
|
||||||
|
checkAdminPermission()
|
||||||
|
return apiPatch(url, data, options, true, responseType)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function apiSuperAdminPatch(url, data = {}, options = {}, responseType = 'json') {
|
||||||
|
checkSuperAdminPermission()
|
||||||
|
return apiPatch(url, data, options, true, responseType)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送DELETE请求
|
* 发送DELETE请求
|
||||||
* @param {string} url - API端点
|
* @param {string} url - API端点
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user