mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
feat: 前后端传递sql编码处理
This commit is contained in:
@@ -14,11 +14,27 @@ class Api {
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* 请求前处理函数
|
||||
* param1: param请求参数
|
||||
*/
|
||||
beforeHandler: Function;
|
||||
|
||||
constructor(url: string, method: string) {
|
||||
this.url = url;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求前处理回调函数
|
||||
* @param func 请求前处理器
|
||||
* @returns this
|
||||
*/
|
||||
withBeforeHandler(func: Function) {
|
||||
this.beforeHandler = func;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限的完整url
|
||||
*/
|
||||
@@ -31,6 +47,9 @@ class Api {
|
||||
* @param {Object} param 请求该api的参数
|
||||
*/
|
||||
request(param: any = null, options: any = null, headers: any = null): Promise<any> {
|
||||
if (this.beforeHandler) {
|
||||
this.beforeHandler(param);
|
||||
}
|
||||
return request.request(this.method, this.url, param, headers, options);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user