Commit a19ba6d9 by Sixong.Zhu

u

parent da2f52b0
Showing with 10 additions and 3 deletions
......@@ -13,23 +13,30 @@ export class BenefitInvoker {
private static readonly unsetupError = '服务尚未初始化';
private static sdk: UniplatSdk | null = null;
private static org = 0;
private static entrance = '';
public static setup(sdk: UniplatSdk, org: number) {
public static setup(sdk: UniplatSdk, org: number, entrance: string) {
this.sdk = sdk;
this.org = org;
this.entrance = entrance;
return this;
}
public static get<T>(service: BenefitServiceName, api: BenefitApiName) {
if (this.sdk) {
return this.sdk.domainService(this.subProject, service, api).request<{}, {}, T>('get', { headers: { CurrentOrg: this.org } });
return this.sdk.domainService(this.subProject, service, api).request<{}, {}, T>('get', {
headers: { CurrentOrg: this.org, Entrance: this.entrance }
});
}
return Promise.reject(this.unsetupError);
}
public static post<T>(service: BenefitServiceName, api: BenefitApiName, data?: any) {
if (this.sdk) {
return this.sdk.domainService(this.subProject, service, api).request<{}, {}, T>('post', { data, headers: { CurrentOrg: this.org } });
return this.sdk.domainService(this.subProject, service, api).request<{}, {}, T>('post', {
data,
headers: { CurrentOrg: this.org, Entrance: this.entrance }
});
}
return Promise.reject(this.unsetupError);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment