feat: getUserDetailInfoV2

This commit is contained in:
手瓜一十雪
2025-01-03 21:38:57 +08:00
parent c499858a5a
commit 35548b3f40
5 changed files with 43 additions and 6 deletions

22
src/common/decorator.ts Normal file
View File

@@ -0,0 +1,22 @@
// decoratorAsyncMethod(this,function,wrapper)
async function decoratorMethod<T, R>(
target: T,
method: () => Promise<R>,
wrapper: (result: R) => Promise<any>,
executeImmediately: boolean = true
): Promise<any> {
const execute = async () => {
try {
const result = await method.call(target);
return wrapper(result);
} catch (error) {
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
}
};
if (executeImmediately) {
return execute();
} else {
return execute;
}
}