52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import type { IGirlService } from "./IGirlService";
|
|
import { HttpGirlService } from "./HttpGirlService";
|
|
import { MockGirlService } from "./MockGirlService";
|
|
import type { ApiResponse } from "../client/types";
|
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|
|
|
// 模拟开关
|
|
const USE_MOCK = false;
|
|
|
|
export class GirlService implements IGirlService {
|
|
private static _I: GirlService | null = null;
|
|
public static get I(): GirlService {
|
|
if (!GirlService._I) GirlService._I = new GirlService();
|
|
return GirlService._I;
|
|
}
|
|
|
|
private impl: IGirlService;
|
|
private constructor() {
|
|
this.impl = USE_MOCK ? new MockGirlService() : new HttpGirlService();
|
|
}
|
|
|
|
/** 可运行期切换 */
|
|
public switch(useMock: boolean) {
|
|
this.impl = useMock ? new MockGirlService() : new HttpGirlService();
|
|
}
|
|
|
|
// 每日推荐
|
|
public async reqDailyRecommend(req: proto.cs.ICSDailyRecommendReq): Promise<ApiResponse<proto.cs.ICSDailyRecommendRes>> {
|
|
return this.impl.reqDailyRecommend(req);
|
|
}
|
|
|
|
// 获取技师列表
|
|
public async reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>> {
|
|
return this.impl.reqGetGirlList(req);
|
|
}
|
|
|
|
// 获取技师详细信息
|
|
public async reqGetGirlDetail(req: proto.cs.ICSGetGirlDetailReq): Promise<ApiResponse<proto.cs.ICSGetGirlDetailRes>> {
|
|
return this.impl.reqGetGirlDetail(req);
|
|
}
|
|
|
|
// 解锁技师
|
|
public async reqUnlockGirl(req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
|
return this.impl.reqUnlockGirl(req);
|
|
}
|
|
|
|
// 解锁资源
|
|
public async reqUnlockGirlRes(req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
|
return this.impl.reqUnlockGirlRes(req);
|
|
}
|
|
}
|