玩家数据

This commit is contained in:
chen wei bo
2025-08-18 15:23:04 +08:00
parent 0a1e33bd55
commit 8f9c5f209a
4 changed files with 66 additions and 6 deletions
@@ -0,0 +1,35 @@
import { ApiClient } from "../client/ApiClient";
import type { Endpoint } from "../client/endpoints";
import type { ApiResponse } from "../client/types";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
export class PlayerDataService {
private static _I: PlayerDataService | null = null;
public static get I(): PlayerDataService {
if (!PlayerDataService._I) PlayerDataService._I = new PlayerDataService();
return PlayerDataService._I;
}
private constructor(private api = ApiClient.I) {}
// 拉取玩家数据
public async reqQueryPlayerData(req: proto.ProtoMsg.IQueryPlayerDataReq): Promise<ApiResponse<proto.ProtoMsg.IQueryPlayerDataRsp>> {
let epData: Endpoint<proto.ProtoMsg.IQueryPlayerDataReq, proto.ProtoMsg.IQueryPlayerDataRsp> = {
path: "playerdata/query_player_data",
method: "POST",
codec: "json",
needsAuth: true
};
return this.api.call(epData, req);
}
// 保存玩家数据
public async reqSavePlayerData(req: proto.ProtoMsg.ISavePlayerDataReq): Promise<ApiResponse<proto.ProtoMsg.ISavePlayerDataRsp>> {
let epData: Endpoint<proto.ProtoMsg.ISavePlayerDataReq, proto.ProtoMsg.ISavePlayerDataRsp> = {
path: "playerdata/save_player_data",
method: "POST",
codec: "json",
needsAuth: true
};
return this.api.call(epData, req);
}
}