协议修改
This commit is contained in:
@@ -61,7 +61,7 @@ export class PurchaseConfig extends BaseConfig {
|
|||||||
// 获取所有 id
|
// 获取所有 id
|
||||||
let resultId = [];
|
let resultId = [];
|
||||||
for (let one of allId) {
|
for (let one of allId) {
|
||||||
const firstDigit = one.toString()[0];
|
const firstDigit = one.toString()[0]; // 取首位字符
|
||||||
if (firstDigit === "2") {
|
if (firstDigit === "2") {
|
||||||
resultId.push(one);
|
resultId.push(one);
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ export class PurchaseConfig extends BaseConfig {
|
|||||||
// 获取所有 id
|
// 获取所有 id
|
||||||
let resultId = [];
|
let resultId = [];
|
||||||
for (let one of allId) {
|
for (let one of allId) {
|
||||||
const firstDigit = one.toString()[0];
|
const firstDigit = one.toString()[0]; // 取首位字符
|
||||||
if (firstDigit === "3") {
|
if (firstDigit === "3") {
|
||||||
resultId.push(one);
|
resultId.push(one);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* 商品数据
|
* 商城数据
|
||||||
*/
|
*/
|
||||||
import { BaseData } from "./BaseData";
|
import { BaseData } from "./BaseData";
|
||||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||||
|
|
||||||
export class ShopData extends BaseData {
|
export class ShopData extends BaseData {
|
||||||
// 商品数据
|
// 商品数据
|
||||||
private _goods = new Map<number, proto.cs.IGood>();
|
private _goods = new Map<number, proto.cs.IPurchaseConfig>();
|
||||||
// 商品 id
|
// 商品 id
|
||||||
private _goodIds: number[] = [];
|
private _goodIds: number[] = [];
|
||||||
|
|
||||||
@@ -27,17 +27,16 @@ export class ShopData extends BaseData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 设置商品数据 */
|
/** 设置商品数据 */
|
||||||
public set goods(res: proto.cs.ICSGetShopRes) {
|
public set goods(res: proto.cs.ICSGetPurchaseRes) {
|
||||||
const list = res.Goods ?? [];
|
const list = res.items ?? [];
|
||||||
this._goods.clear();
|
this._goods.clear();
|
||||||
this._goodIds = [];
|
this._goodIds = [];
|
||||||
for (const g of list) {
|
for (const g of list) {
|
||||||
const vo: proto.cs.IGood = {
|
const vo: proto.cs.IPurchaseConfig = {
|
||||||
id: g.id, // 商品 id
|
id: g.id, // 商品 id
|
||||||
name: g.name || "", // 商品名字
|
name: g.name, // 商品名字
|
||||||
desc: g.desc || "", // 商品描述
|
count: g.count, // 商品数量
|
||||||
price: g.price || "0.00", // 商品价格
|
price: g.price, // 商品价格
|
||||||
count: g.count || 0, // 商品数量
|
|
||||||
};
|
};
|
||||||
this._goods.set(vo.id, vo);
|
this._goods.set(vo.id, vo);
|
||||||
this._goodIds.push(vo.id);
|
this._goodIds.push(vo.id);
|
||||||
@@ -46,7 +45,7 @@ export class ShopData extends BaseData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 获取所有商品数据 */
|
/** 获取所有商品数据 */
|
||||||
public get goods(): Map<number, proto.cs.IGood> { return this._goods; }
|
public get goods(): Map<number, proto.cs.IPurchaseConfig> { return this._goods; }
|
||||||
|
|
||||||
/** 获取所有商品数据的数量 */
|
/** 获取所有商品数据的数量 */
|
||||||
public get goodsCount(): number { return this._goods ? this._goods.size : 0; }
|
public get goodsCount(): number { return this._goods ? this._goods.size : 0; }
|
||||||
@@ -54,18 +53,53 @@ export class ShopData extends BaseData {
|
|||||||
/** 获取所有商品 id */
|
/** 获取所有商品 id */
|
||||||
public get goodIds(): number[] { return this._goodIds; }
|
public get goodIds(): number[] { return this._goodIds; }
|
||||||
|
|
||||||
/** 获取vip商品数据 */
|
/** 获取 充值商品的id数组,首位数字为 1 */
|
||||||
public get vipGoods(): proto.cs.IGood[] {
|
private getRechargeIds(): number[] {
|
||||||
return this._goodIds.map(id => this._goods.get(id)!).filter(g => g.id > 2000);
|
let allId = this._goodIds;
|
||||||
|
if (!allId) return [];
|
||||||
|
// 获取所有 id
|
||||||
|
let resultId = [];
|
||||||
|
for (let one of allId) {
|
||||||
|
const firstDigit = one.toString()[0]; // 取首位字符
|
||||||
|
if (firstDigit === "1") {
|
||||||
|
resultId.push(one);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取普通商品数据 */
|
/** 获取 会员商品的id数组,首位数字为 2 */
|
||||||
public get normalGoods(): proto.cs.IGood[] {
|
private getMemberIds(): number[] {
|
||||||
return this._goodIds.map(id => this._goods.get(id)!).filter(g => g.id <= 2000);
|
let allId = this._goodIds;
|
||||||
|
if (!allId) return [];
|
||||||
|
// 获取所有 id
|
||||||
|
let resultId = [];
|
||||||
|
for (let one of allId) {
|
||||||
|
const firstDigit = one.toString()[0]; // 取首位字符
|
||||||
|
if (firstDigit === "2") {
|
||||||
|
resultId.push(one);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取 聊天商品的id数组,首位数字为 3 */
|
||||||
|
private getChatIds(): number[] {
|
||||||
|
let allId = this._goodIds;
|
||||||
|
if (!allId) return [];
|
||||||
|
// 获取所有 id
|
||||||
|
let resultId = [];
|
||||||
|
for (let one of allId) {
|
||||||
|
const firstDigit = one.toString()[0]; // 取首位字符
|
||||||
|
if (firstDigit === "3") {
|
||||||
|
resultId.push(one);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
/** 根据商品 id 获取商品数据 */
|
/** 根据商品 id 获取商品数据 */
|
||||||
private getGoodDataById(id: number): proto.cs.IGood | null {
|
private getGoodDataById(id: number): proto.cs.IPurchaseConfig | null {
|
||||||
if (!this._goods) return null;
|
if (!this._goods) return null;
|
||||||
return this._goods.get(id) ?? null;
|
return this._goods.get(id) ?? null;
|
||||||
}
|
}
|
||||||
@@ -77,15 +111,8 @@ export class ShopData extends BaseData {
|
|||||||
return oneData.name;
|
return oneData.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 根据商品 id 获取商品描述 */
|
|
||||||
public getDescById(id: number): string | null {
|
|
||||||
let oneData = this.getGoodDataById(id);
|
|
||||||
if (!oneData) return null;
|
|
||||||
return oneData.desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 根据商品 id 获取商品价格 */
|
/** 根据商品 id 获取商品价格 */
|
||||||
public getPriceById(id: number): string | null {
|
public getPriceById(id: number): number | null {
|
||||||
let oneData = this.getGoodDataById(id);
|
let oneData = this.getGoodDataById(id);
|
||||||
if (!oneData) return null;
|
if (!oneData) return null;
|
||||||
return oneData.price;
|
return oneData.price;
|
||||||
|
|||||||
@@ -26,8 +26,18 @@ export class ChatService implements IChatService {
|
|||||||
this.impl = useMock ? new MockChatService() : new HttpChatService();
|
this.impl = useMock ? new MockChatService() : new HttpChatService();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对外 API 保持不变
|
// 上报聊天数据
|
||||||
public async reqBuyChat(req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>> {
|
public async reqChatMsg(req: proto.cs.ICSChatMsgReq): Promise<ApiResponse<proto.cs.ICSChatMsgRes>> {
|
||||||
return this.impl.reqBuyChat(req);
|
return this.impl.reqChatMsg(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取聊天数据
|
||||||
|
public async reqGetChatMsg(req: proto.cs.ICSGetChatMsgReq): Promise<ApiResponse<proto.cs.ICSGetChatMsgRes>> {
|
||||||
|
return this.impl.reqGetChatMsg(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取技师聊天次数
|
||||||
|
public async reqChatCountData(req: proto.cs.ICSGetChatRemainCountReq): Promise<ApiResponse<proto.cs.ICSGetChatRemainCountRes>> {
|
||||||
|
return this.impl.reqChatCountData(req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,14 @@ export class GirlService implements IGirlService {
|
|||||||
public async reqGetGirlDetail(req: proto.cs.ICSGetGirlDetailReq): Promise<ApiResponse<proto.cs.ICSGetGirlDetailRes>> {
|
public async reqGetGirlDetail(req: proto.cs.ICSGetGirlDetailReq): Promise<ApiResponse<proto.cs.ICSGetGirlDetailRes>> {
|
||||||
return this.impl.reqGetGirlDetail(req);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,36 @@ import type { IChatService } from "./IChatService";
|
|||||||
export class HttpChatService implements IChatService {
|
export class HttpChatService implements IChatService {
|
||||||
constructor(private api = ApiClient.I) {}
|
constructor(private api = ApiClient.I) {}
|
||||||
|
|
||||||
// 购买聊天次数
|
// 上报聊天数据
|
||||||
async reqBuyChat(req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>> {
|
async reqChatMsg(req: proto.cs.ICSChatMsgReq): Promise<ApiResponse<proto.cs.ICSChatMsgRes>> {
|
||||||
const ep: Endpoint<proto.cs.ICSBuyChatReq, proto.cs.ICSBuyChatRes> = {
|
const ep: Endpoint<proto.cs.ICSChatMsgReq, proto.cs.ICSChatMsgRes> = {
|
||||||
path: "api/logic/buyChat",
|
path: "api/logic/chatMsg",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
codec: "json",
|
codec: "json",
|
||||||
needsAuth: true,
|
needsAuth: true,
|
||||||
};
|
};
|
||||||
return this.api.call(ep, req);
|
return this.api.call(ep, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取聊天数据
|
||||||
|
async reqGetChatMsg(req: proto.cs.ICSGetChatMsgReq): Promise<ApiResponse<proto.cs.ICSGetChatMsgRes>> {
|
||||||
|
const ep: Endpoint<proto.cs.ICSGetChatMsgReq, proto.cs.ICSGetChatMsgRes> = {
|
||||||
|
path: "api/logic/getChatMsg",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true,
|
||||||
|
};
|
||||||
|
return this.api.call(ep, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取技师聊天次数
|
||||||
|
async reqChatCountData(req: proto.cs.ICSGetChatRemainCountReq): Promise<ApiResponse<proto.cs.ICSGetChatRemainCountRes>> {
|
||||||
|
const ep: Endpoint<proto.cs.ICSGetChatRemainCountReq, proto.cs.ICSGetChatRemainCountRes> = {
|
||||||
|
path: "api/logic/getChatRemainCount",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true,
|
||||||
|
};
|
||||||
|
return this.api.call(ep, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,4 +39,26 @@ export class HttpGirlService implements IGirlService {
|
|||||||
};
|
};
|
||||||
return this.api.call(epData, req);
|
return this.api.call(epData, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解锁技师
|
||||||
|
async reqUnlockGirl(req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||||
|
let epData: Endpoint<proto.cs.ICSUnlockGirlReq, proto.cs.ICSUnlockGirlRes> = {
|
||||||
|
path: "api/logic/unlockGirl",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true
|
||||||
|
};
|
||||||
|
return this.api.call(epData, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解锁资源
|
||||||
|
async reqUnlockGirlRes(req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||||
|
let epData: Endpoint<proto.cs.ICSUnlockResourceReq, proto.cs.ICSUnlockResourceRes> = {
|
||||||
|
path: "api/logic/unlockResource",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true
|
||||||
|
};
|
||||||
|
return this.api.call(epData, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,24 @@ export class HttpShopService implements IShopService {
|
|||||||
constructor(private api = ApiClient.I) {}
|
constructor(private api = ApiClient.I) {}
|
||||||
|
|
||||||
// 获取商品列表
|
// 获取商品列表
|
||||||
async reqShopList(req: proto.cs.ICSGetShopReq): Promise<ApiResponse<proto.cs.ICSGetShopRes>> {
|
async reqShopList(req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||||
const ep: Endpoint<proto.cs.ICSGetShopReq, proto.cs.ICSGetShopRes> = {
|
const ep: Endpoint<proto.cs.ICSGetPurchaseReq, proto.cs.ICSGetPurchaseRes> = {
|
||||||
path: "api/logic/shop",
|
path: "api/logic/getPurchase",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
codec: "json",
|
codec: "json",
|
||||||
needsAuth: true,
|
needsAuth: true,
|
||||||
};
|
};
|
||||||
return this.api.call(ep, req);
|
return this.api.call(ep, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用余额购买商品
|
||||||
|
async reqBuyGood(req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||||
|
const ep: Endpoint<proto.cs.ICSBuyGoodReq, proto.cs.ICSBuyGoodRes> = {
|
||||||
|
path: "api/logic/buyGood",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true,
|
||||||
|
};
|
||||||
|
return this.api.call(ep, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import type { ApiResponse } from "../client/types";
|
|||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||||
|
|
||||||
export interface IChatService {
|
export interface IChatService {
|
||||||
// 购买聊天次数
|
// 上报聊天数据
|
||||||
reqBuyChat(req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>>;
|
reqChatMsg(req: proto.cs.ICSChatMsgReq): Promise<ApiResponse<proto.cs.ICSChatMsgRes>>;
|
||||||
|
// 获取聊天数据
|
||||||
|
reqGetChatMsg(req: proto.cs.ICSGetChatMsgReq): Promise<ApiResponse<proto.cs.ICSGetChatMsgRes>>;
|
||||||
|
// 获取技师聊天次数
|
||||||
|
reqChatCountData(req: proto.cs.ICSGetChatRemainCountReq): Promise<ApiResponse<proto.cs.ICSGetChatRemainCountRes>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,8 @@ export interface IGirlService {
|
|||||||
reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>>;
|
reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>>;
|
||||||
// 获取技师详细信息
|
// 获取技师详细信息
|
||||||
reqGetGirlDetail(req: proto.cs.ICSGetGirlDetailReq): Promise<ApiResponse<proto.cs.ICSGetGirlDetailRes>>;
|
reqGetGirlDetail(req: proto.cs.ICSGetGirlDetailReq): Promise<ApiResponse<proto.cs.ICSGetGirlDetailRes>>;
|
||||||
|
// 解锁技师
|
||||||
|
reqUnlockGirl(req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>>;
|
||||||
|
// 解锁资源
|
||||||
|
reqUnlockGirlRes(req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|||||||
|
|
||||||
export interface IShopService {
|
export interface IShopService {
|
||||||
// 获取商品列表
|
// 获取商品列表
|
||||||
reqShopList(req: proto.cs.ICSGetShopReq): Promise<ApiResponse<proto.cs.ICSGetShopRes>>;
|
reqShopList(req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>>;
|
||||||
|
// 使用余额购买商品
|
||||||
|
reqBuyGood(req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,91 @@
|
|||||||
import type { ApiResponse } from "../client/types";
|
import type { ApiResponse } from "../client/types";
|
||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||||
import type { IChatService } from "./IChatService";
|
import type { IChatService } from "./IChatService";
|
||||||
|
import { DataManager, DataId } from "../../data/DataManager";
|
||||||
|
import { GirlData } from "../../data/GirlData";
|
||||||
|
|
||||||
export class MockChatService implements IChatService {
|
export class MockChatService implements IChatService {
|
||||||
private delay(ms = 160) { return new Promise<void>(r => setTimeout(r, ms)); }
|
private delay(ms = 160) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||||
|
|
||||||
// 按你们项目的 ApiResponse 结构调整这里即可
|
|
||||||
private ok<T>(data: T): ApiResponse<T> {
|
private ok<T>(data: T): ApiResponse<T> {
|
||||||
return ({ ok: true, data } as unknown) as ApiResponse<T>;
|
return ({ code: proto.cs.EnmRetCode.SUCCESS, data } as unknown) as ApiResponse<T>;
|
||||||
}
|
}
|
||||||
// private err<T = unknown>(message = "mock buyChat error"): ApiResponse<T> {
|
|
||||||
// return ({ ok: false, error: { message } } as unknown) as ApiResponse<T>;
|
|
||||||
// }
|
|
||||||
|
|
||||||
async reqBuyChat(_req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>> {
|
// 上报聊天数据
|
||||||
|
async reqChatMsg(req: proto.cs.ICSChatMsgReq): Promise<ApiResponse<proto.cs.ICSChatMsgRes>> {
|
||||||
|
// 延时
|
||||||
await this.delay();
|
await this.delay();
|
||||||
// CSBuyChatRes 在 proto 中为空消息,这里返回 {}
|
// 请求数据
|
||||||
const res: proto.cs.ICSBuyChatRes = {};
|
const reqGirlId = req.girlId;
|
||||||
|
// 数据层的数据
|
||||||
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
|
const reqGirlCategory = girlData.getGrilCategoryById(reqGirlId);
|
||||||
|
const chatTotalCount = girlData.getChatTotalCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
const chatRemainCount = girlData.getChatRemainCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
// 计算
|
||||||
|
let resultTotalCount = chatTotalCount + 1;
|
||||||
|
let resultRemainCount = chatRemainCount;
|
||||||
|
if (chatRemainCount > 0) {
|
||||||
|
resultRemainCount = chatRemainCount - 1;
|
||||||
|
}
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSChatMsgRes = {
|
||||||
|
chatRemainCount: resultRemainCount,
|
||||||
|
chatTotalCount: resultTotalCount,
|
||||||
|
};
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取聊天数据
|
||||||
|
async reqGetChatMsg(req: proto.cs.ICSGetChatMsgReq): Promise<ApiResponse<proto.cs.ICSGetChatMsgRes>> {
|
||||||
|
// 延时
|
||||||
|
await this.delay();
|
||||||
|
// 请求数据
|
||||||
|
const reqGirlId = req.GirlId;
|
||||||
|
const page = req.page;
|
||||||
|
const limit = req.limit;
|
||||||
|
// 数据层的数据
|
||||||
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
|
const reqGirlCategory = girlData.getGrilCategoryById(reqGirlId);
|
||||||
|
const chatTotalCount = girlData.getChatTotalCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
const chatRemainCount = girlData.getChatRemainCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
// 模拟一个完整的聊天记录池
|
||||||
|
const allMsgs: proto.cs.IChatMsg[] = [];
|
||||||
|
for (let i = 0; i < 50; i++) {
|
||||||
|
allMsgs.push({
|
||||||
|
msg: `模拟消息 ${i + 1} 来自技师 ${reqGirlId}`,
|
||||||
|
isAi: i % 2 === 0, // 偶数条当成 AI 说的
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 分页计算
|
||||||
|
const start = (page - 1) * limit;
|
||||||
|
const end = start + limit;
|
||||||
|
const pageMsgs = allMsgs.slice(start, end);
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSGetChatMsgRes = {
|
||||||
|
msgs: pageMsgs,
|
||||||
|
chatRemainCount,
|
||||||
|
chatTotalCount,
|
||||||
|
};
|
||||||
|
return this.ok(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取技师聊天次数
|
||||||
|
async reqChatCountData(req: proto.cs.ICSGetChatRemainCountReq): Promise<ApiResponse<proto.cs.ICSGetChatRemainCountRes>> {
|
||||||
|
// 延时
|
||||||
|
await this.delay();
|
||||||
|
// 请求数据
|
||||||
|
const reqGirlId = req.id;
|
||||||
|
// 数据层的数据
|
||||||
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
|
const reqGirlCategory = girlData.getGrilCategoryById(reqGirlId);
|
||||||
|
const chatTotalCount = girlData.getChatTotalCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
const chatRemainCount = girlData.getChatRemainCount(reqGirlCategory.toString(), reqGirlId);
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSGetChatRemainCountRes = {
|
||||||
|
chatRemainCount,
|
||||||
|
chatTotalCount,
|
||||||
|
};
|
||||||
|
return this.ok(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,12 +226,30 @@ export class MockGirlService implements IGirlService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const star = 3;
|
const star = 3;
|
||||||
const chatTotalCount = 10;
|
const chatTotalCount = 20;
|
||||||
const chatRemainCount = 10;
|
const chatRemainCount = 20;
|
||||||
|
|
||||||
const girlData = this.genGirlData(girlId, briefData, isRelease, star, detail, unlockImageData, unlockVideoData, chatTotalCount, chatRemainCount);
|
const girlData = this.genGirlData(girlId, briefData, isRelease, star, detail, unlockImageData, unlockVideoData, chatTotalCount, chatRemainCount);
|
||||||
// 返回数据
|
// 返回数据
|
||||||
const res: proto.cs.ICSGetGirlDetailRes = {girl: girlData};
|
const res: proto.cs.ICSGetGirlDetailRes = {girl: girlData};
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解锁技师
|
||||||
|
async reqUnlockGirl(_req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||||
|
// 延时
|
||||||
|
await this.delay(180);
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSUnlockGirlRes = {};
|
||||||
|
return this.ok(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解锁资源
|
||||||
|
async reqUnlockGirlRes(_req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||||
|
// 延时
|
||||||
|
await this.delay(180);
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSUnlockResourceRes = {};
|
||||||
|
return this.ok(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { ApiResponse } from "../client/types";
|
import type { ApiResponse } from "../client/types";
|
||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||||
import type { IShopService } from "./IShopService";
|
import type { IShopService } from "./IShopService";
|
||||||
|
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
||||||
|
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||||
|
|
||||||
export class MockShopService implements IShopService {
|
export class MockShopService implements IShopService {
|
||||||
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||||
@@ -11,29 +13,44 @@ export class MockShopService implements IShopService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ok<T>(data: T): ApiResponse<T> {
|
private ok<T>(data: T): ApiResponse<T> {
|
||||||
return ({ ok: true, data } as unknown) as ApiResponse<T>;
|
return ({ code: proto.cs.EnmRetCode.SUCCESS, data } as unknown) as ApiResponse<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
private genGood(id: number, vip = false): proto.cs.IGood {
|
private genGood(id: number, name: string, count: number, price: number): proto.cs.IPurchaseConfig {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
name: vip ? `VIP-${id}` : `Diamond Pack ${id}`,
|
name,
|
||||||
desc: vip ? `VIP access for ${this.randInt(24, 168)} hours` : `Diamonds x${this.randInt(60, 2000)}`,
|
count,
|
||||||
price: this.priceUSD(vip ? 4.99 : 0.99, vip ? 49.99 : 29.99),
|
price,
|
||||||
count: vip ? this.randInt(24, 168) : this.randInt(60, 2000), // VIP=小时,普通=数量
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品列表
|
// 获取商品列表
|
||||||
async reqShopList(_req: proto.cs.ICSGetShopReq): Promise<ApiResponse<proto.cs.ICSGetShopRes>> {
|
async reqShopList(_req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||||
|
// 延时
|
||||||
await this.delay();
|
await this.delay();
|
||||||
|
// 配置数据
|
||||||
// 普通商品(<=2000)+ VIP 商品(>2000)
|
const configData = ConfigManager.I.getDataById<PurchaseConfig>(ConfigId.Purchase);
|
||||||
const normals: proto.cs.IGood[] = Array.from({ length: 5 }, (_, i) => this.genGood(1000 + i, false));
|
const allId = configData.getAllId();
|
||||||
const vips: proto.cs.IGood[] = Array.from({ length: 3 }, (_, i) => this.genGood(2001 + i, true));
|
let goodData: proto.cs.IPurchaseConfig[] = [];
|
||||||
|
for (let id of allId) {
|
||||||
// 注意:你的 proto 定义中字段名为 "Goods"(大写 G)
|
let name = configData.getNameById(id);
|
||||||
const res: proto.cs.ICSGetShopRes = { Goods: [...normals, ...vips] };
|
let count = configData.getCountById(id);
|
||||||
|
let price = configData.getPriceById(id);
|
||||||
|
let oneData = this.genGood(id, name, count, price);
|
||||||
|
goodData.push(oneData);
|
||||||
|
}
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSGetPurchaseRes = { items: goodData };
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用余额购买商品
|
||||||
|
async reqBuyGood(_req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||||
|
// 延时
|
||||||
|
await this.delay();
|
||||||
|
// 返回数据
|
||||||
|
const res: proto.cs.ICSBuyGoodRes = {};
|
||||||
|
return this.ok(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ export class ShopService implements IShopService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品列表
|
// 获取商品列表
|
||||||
public async reqShopList(req: proto.cs.ICSGetShopReq): Promise<ApiResponse<proto.cs.ICSGetShopRes>> {
|
public async reqShopList(req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||||
return this.impl.reqShopList(req);
|
return this.impl.reqShopList(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用余额购买商品
|
||||||
|
public async reqBuyGood(req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||||
|
return this.impl.reqBuyGood(req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+188
@@ -2951,6 +2951,194 @@ toJSON(): { [k: string]: any };
|
|||||||
static getTypeUrl(typeUrlPrefix?: string): string;
|
static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Properties of a CSGetPurchaseReq. */
|
||||||
|
interface ICSGetPurchaseReq {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a CSGetPurchaseReq. */
|
||||||
|
class CSGetPurchaseReq implements ICSGetPurchaseReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CSGetPurchaseReq.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: cs.ICSGetPurchaseReq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CSGetPurchaseReq instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns CSGetPurchaseReq instance
|
||||||
|
*/
|
||||||
|
static create(properties?: cs.ICSGetPurchaseReq): cs.CSGetPurchaseReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseReq message. Does not implicitly {@link cs.CSGetPurchaseReq.verify|verify} messages.
|
||||||
|
* @param message CSGetPurchaseReq message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
static encode(message: cs.ICSGetPurchaseReq, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseReq message, length delimited. Does not implicitly {@link cs.CSGetPurchaseReq.verify|verify} messages.
|
||||||
|
* @param message CSGetPurchaseReq message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
static encodeDelimited(message: cs.ICSGetPurchaseReq, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseReq message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns CSGetPurchaseReq
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): cs.CSGetPurchaseReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseReq message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns CSGetPurchaseReq
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): cs.CSGetPurchaseReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a CSGetPurchaseReq message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CSGetPurchaseReq message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns CSGetPurchaseReq
|
||||||
|
*/
|
||||||
|
static fromObject(object: { [k: string]: any }): cs.CSGetPurchaseReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a CSGetPurchaseReq message. Also converts values to other types if specified.
|
||||||
|
* @param message CSGetPurchaseReq
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
static toObject(message: cs.CSGetPurchaseReq, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this CSGetPurchaseReq to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for CSGetPurchaseReq
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a CSGetPurchaseRes. */
|
||||||
|
interface ICSGetPurchaseRes {
|
||||||
|
|
||||||
|
/** CSGetPurchaseRes items */
|
||||||
|
items?: (cs.IPurchaseConfig[]|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a CSGetPurchaseRes. */
|
||||||
|
class CSGetPurchaseRes implements ICSGetPurchaseRes {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CSGetPurchaseRes.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: cs.ICSGetPurchaseRes);
|
||||||
|
|
||||||
|
/** CSGetPurchaseRes items. */
|
||||||
|
items: cs.IPurchaseConfig[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CSGetPurchaseRes instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns CSGetPurchaseRes instance
|
||||||
|
*/
|
||||||
|
static create(properties?: cs.ICSGetPurchaseRes): cs.CSGetPurchaseRes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseRes message. Does not implicitly {@link cs.CSGetPurchaseRes.verify|verify} messages.
|
||||||
|
* @param message CSGetPurchaseRes message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
static encode(message: cs.ICSGetPurchaseRes, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseRes message, length delimited. Does not implicitly {@link cs.CSGetPurchaseRes.verify|verify} messages.
|
||||||
|
* @param message CSGetPurchaseRes message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
static encodeDelimited(message: cs.ICSGetPurchaseRes, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseRes message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns CSGetPurchaseRes
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): cs.CSGetPurchaseRes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseRes message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns CSGetPurchaseRes
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): cs.CSGetPurchaseRes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a CSGetPurchaseRes message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CSGetPurchaseRes message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns CSGetPurchaseRes
|
||||||
|
*/
|
||||||
|
static fromObject(object: { [k: string]: any }): cs.CSGetPurchaseRes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a CSGetPurchaseRes message. Also converts values to other types if specified.
|
||||||
|
* @param message CSGetPurchaseRes
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
static toObject(message: cs.CSGetPurchaseRes, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this CSGetPurchaseRes to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for CSGetPurchaseRes
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
/** Category enum. */
|
/** Category enum. */
|
||||||
enum Category {
|
enum Category {
|
||||||
Category_mature = 0,
|
Category_mature = 0,
|
||||||
|
|||||||
@@ -6625,6 +6625,409 @@ $root.cs = (function() {
|
|||||||
return CSGetResConfigRes;
|
return CSGetResConfigRes;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
cs.CSGetPurchaseReq = (function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties of a CSGetPurchaseReq.
|
||||||
|
* @memberof cs
|
||||||
|
* @interface ICSGetPurchaseReq
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CSGetPurchaseReq.
|
||||||
|
* @memberof cs
|
||||||
|
* @classdesc Represents a CSGetPurchaseReq.
|
||||||
|
* @implements ICSGetPurchaseReq
|
||||||
|
* @constructor
|
||||||
|
* @param {cs.ICSGetPurchaseReq=} [properties] Properties to set
|
||||||
|
*/
|
||||||
|
function CSGetPurchaseReq(properties) {
|
||||||
|
if (properties)
|
||||||
|
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
||||||
|
if (properties[keys[i]] != null)
|
||||||
|
this[keys[i]] = properties[keys[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CSGetPurchaseReq instance using the specified properties.
|
||||||
|
* @function create
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseReq=} [properties] Properties to set
|
||||||
|
* @returns {cs.CSGetPurchaseReq} CSGetPurchaseReq instance
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.create = function create(properties) {
|
||||||
|
return new CSGetPurchaseReq(properties);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseReq message. Does not implicitly {@link cs.CSGetPurchaseReq.verify|verify} messages.
|
||||||
|
* @function encode
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseReq} message CSGetPurchaseReq message or plain object to encode
|
||||||
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
||||||
|
* @returns {$protobuf.Writer} Writer
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.encode = function encode(message, writer) {
|
||||||
|
if (!writer)
|
||||||
|
writer = $Writer.create();
|
||||||
|
return writer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseReq message, length delimited. Does not implicitly {@link cs.CSGetPurchaseReq.verify|verify} messages.
|
||||||
|
* @function encodeDelimited
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseReq} message CSGetPurchaseReq message or plain object to encode
|
||||||
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
||||||
|
* @returns {$protobuf.Writer} Writer
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.encodeDelimited = function encodeDelimited(message, writer) {
|
||||||
|
return this.encode(message, writer).ldelim();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseReq message from the specified reader or buffer.
|
||||||
|
* @function decode
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
||||||
|
* @param {number} [length] Message length if known beforehand
|
||||||
|
* @returns {cs.CSGetPurchaseReq} CSGetPurchaseReq
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.decode = function decode(reader, length, error) {
|
||||||
|
if (!(reader instanceof $Reader))
|
||||||
|
reader = $Reader.create(reader);
|
||||||
|
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.cs.CSGetPurchaseReq();
|
||||||
|
while (reader.pos < end) {
|
||||||
|
var tag = reader.uint32();
|
||||||
|
if (tag === error)
|
||||||
|
break;
|
||||||
|
switch (tag >>> 3) {
|
||||||
|
default:
|
||||||
|
reader.skipType(tag & 7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseReq message from the specified reader or buffer, length delimited.
|
||||||
|
* @function decodeDelimited
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
||||||
|
* @returns {cs.CSGetPurchaseReq} CSGetPurchaseReq
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.decodeDelimited = function decodeDelimited(reader) {
|
||||||
|
if (!(reader instanceof $Reader))
|
||||||
|
reader = new $Reader(reader);
|
||||||
|
return this.decode(reader, reader.uint32());
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a CSGetPurchaseReq message.
|
||||||
|
* @function verify
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {Object.<string,*>} message Plain object to verify
|
||||||
|
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.verify = function verify(message) {
|
||||||
|
if (typeof message !== "object" || message === null)
|
||||||
|
return "object expected";
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CSGetPurchaseReq message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @function fromObject
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {Object.<string,*>} object Plain object
|
||||||
|
* @returns {cs.CSGetPurchaseReq} CSGetPurchaseReq
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.fromObject = function fromObject(object) {
|
||||||
|
if (object instanceof $root.cs.CSGetPurchaseReq)
|
||||||
|
return object;
|
||||||
|
return new $root.cs.CSGetPurchaseReq();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a CSGetPurchaseReq message. Also converts values to other types if specified.
|
||||||
|
* @function toObject
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {cs.CSGetPurchaseReq} message CSGetPurchaseReq
|
||||||
|
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
||||||
|
* @returns {Object.<string,*>} Plain object
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.toObject = function toObject() {
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this CSGetPurchaseReq to JSON.
|
||||||
|
* @function toJSON
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @instance
|
||||||
|
* @returns {Object.<string,*>} JSON object
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.prototype.toJSON = function toJSON() {
|
||||||
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for CSGetPurchaseReq
|
||||||
|
* @function getTypeUrl
|
||||||
|
* @memberof cs.CSGetPurchaseReq
|
||||||
|
* @static
|
||||||
|
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns {string} The default type url
|
||||||
|
*/
|
||||||
|
CSGetPurchaseReq.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
||||||
|
if (typeUrlPrefix === undefined) {
|
||||||
|
typeUrlPrefix = "type.googleapis.com";
|
||||||
|
}
|
||||||
|
return typeUrlPrefix + "/cs.CSGetPurchaseReq";
|
||||||
|
};
|
||||||
|
|
||||||
|
return CSGetPurchaseReq;
|
||||||
|
})();
|
||||||
|
|
||||||
|
cs.CSGetPurchaseRes = (function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties of a CSGetPurchaseRes.
|
||||||
|
* @memberof cs
|
||||||
|
* @interface ICSGetPurchaseRes
|
||||||
|
* @property {Array.<cs.IPurchaseConfig>|null} [items] CSGetPurchaseRes items
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CSGetPurchaseRes.
|
||||||
|
* @memberof cs
|
||||||
|
* @classdesc Represents a CSGetPurchaseRes.
|
||||||
|
* @implements ICSGetPurchaseRes
|
||||||
|
* @constructor
|
||||||
|
* @param {cs.ICSGetPurchaseRes=} [properties] Properties to set
|
||||||
|
*/
|
||||||
|
function CSGetPurchaseRes(properties) {
|
||||||
|
this.items = [];
|
||||||
|
if (properties)
|
||||||
|
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
||||||
|
if (properties[keys[i]] != null)
|
||||||
|
this[keys[i]] = properties[keys[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CSGetPurchaseRes items.
|
||||||
|
* @member {Array.<cs.IPurchaseConfig>} items
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @instance
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.prototype.items = $util.emptyArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CSGetPurchaseRes instance using the specified properties.
|
||||||
|
* @function create
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseRes=} [properties] Properties to set
|
||||||
|
* @returns {cs.CSGetPurchaseRes} CSGetPurchaseRes instance
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.create = function create(properties) {
|
||||||
|
return new CSGetPurchaseRes(properties);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseRes message. Does not implicitly {@link cs.CSGetPurchaseRes.verify|verify} messages.
|
||||||
|
* @function encode
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseRes} message CSGetPurchaseRes message or plain object to encode
|
||||||
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
||||||
|
* @returns {$protobuf.Writer} Writer
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.encode = function encode(message, writer) {
|
||||||
|
if (!writer)
|
||||||
|
writer = $Writer.create();
|
||||||
|
if (message.items != null && message.items.length)
|
||||||
|
for (var i = 0; i < message.items.length; ++i)
|
||||||
|
$root.cs.PurchaseConfig.encode(message.items[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
|
||||||
|
return writer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified CSGetPurchaseRes message, length delimited. Does not implicitly {@link cs.CSGetPurchaseRes.verify|verify} messages.
|
||||||
|
* @function encodeDelimited
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {cs.ICSGetPurchaseRes} message CSGetPurchaseRes message or plain object to encode
|
||||||
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
||||||
|
* @returns {$protobuf.Writer} Writer
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.encodeDelimited = function encodeDelimited(message, writer) {
|
||||||
|
return this.encode(message, writer).ldelim();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseRes message from the specified reader or buffer.
|
||||||
|
* @function decode
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
||||||
|
* @param {number} [length] Message length if known beforehand
|
||||||
|
* @returns {cs.CSGetPurchaseRes} CSGetPurchaseRes
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.decode = function decode(reader, length, error) {
|
||||||
|
if (!(reader instanceof $Reader))
|
||||||
|
reader = $Reader.create(reader);
|
||||||
|
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.cs.CSGetPurchaseRes();
|
||||||
|
while (reader.pos < end) {
|
||||||
|
var tag = reader.uint32();
|
||||||
|
if (tag === error)
|
||||||
|
break;
|
||||||
|
switch (tag >>> 3) {
|
||||||
|
case 1: {
|
||||||
|
if (!(message.items && message.items.length))
|
||||||
|
message.items = [];
|
||||||
|
message.items.push($root.cs.PurchaseConfig.decode(reader, reader.uint32()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
reader.skipType(tag & 7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a CSGetPurchaseRes message from the specified reader or buffer, length delimited.
|
||||||
|
* @function decodeDelimited
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
||||||
|
* @returns {cs.CSGetPurchaseRes} CSGetPurchaseRes
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.decodeDelimited = function decodeDelimited(reader) {
|
||||||
|
if (!(reader instanceof $Reader))
|
||||||
|
reader = new $Reader(reader);
|
||||||
|
return this.decode(reader, reader.uint32());
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a CSGetPurchaseRes message.
|
||||||
|
* @function verify
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {Object.<string,*>} message Plain object to verify
|
||||||
|
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.verify = function verify(message) {
|
||||||
|
if (typeof message !== "object" || message === null)
|
||||||
|
return "object expected";
|
||||||
|
if (message.items != null && message.hasOwnProperty("items")) {
|
||||||
|
if (!Array.isArray(message.items))
|
||||||
|
return "items: array expected";
|
||||||
|
for (var i = 0; i < message.items.length; ++i) {
|
||||||
|
var error = $root.cs.PurchaseConfig.verify(message.items[i]);
|
||||||
|
if (error)
|
||||||
|
return "items." + error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CSGetPurchaseRes message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @function fromObject
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {Object.<string,*>} object Plain object
|
||||||
|
* @returns {cs.CSGetPurchaseRes} CSGetPurchaseRes
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.fromObject = function fromObject(object) {
|
||||||
|
if (object instanceof $root.cs.CSGetPurchaseRes)
|
||||||
|
return object;
|
||||||
|
var message = new $root.cs.CSGetPurchaseRes();
|
||||||
|
if (object.items) {
|
||||||
|
if (!Array.isArray(object.items))
|
||||||
|
throw TypeError(".cs.CSGetPurchaseRes.items: array expected");
|
||||||
|
message.items = [];
|
||||||
|
for (var i = 0; i < object.items.length; ++i) {
|
||||||
|
if (typeof object.items[i] !== "object")
|
||||||
|
throw TypeError(".cs.CSGetPurchaseRes.items: object expected");
|
||||||
|
message.items[i] = $root.cs.PurchaseConfig.fromObject(object.items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a CSGetPurchaseRes message. Also converts values to other types if specified.
|
||||||
|
* @function toObject
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {cs.CSGetPurchaseRes} message CSGetPurchaseRes
|
||||||
|
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
||||||
|
* @returns {Object.<string,*>} Plain object
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.toObject = function toObject(message, options) {
|
||||||
|
if (!options)
|
||||||
|
options = {};
|
||||||
|
var object = {};
|
||||||
|
if (options.arrays || options.defaults)
|
||||||
|
object.items = [];
|
||||||
|
if (message.items && message.items.length) {
|
||||||
|
object.items = [];
|
||||||
|
for (var j = 0; j < message.items.length; ++j)
|
||||||
|
object.items[j] = $root.cs.PurchaseConfig.toObject(message.items[j], options);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this CSGetPurchaseRes to JSON.
|
||||||
|
* @function toJSON
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @instance
|
||||||
|
* @returns {Object.<string,*>} JSON object
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.prototype.toJSON = function toJSON() {
|
||||||
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for CSGetPurchaseRes
|
||||||
|
* @function getTypeUrl
|
||||||
|
* @memberof cs.CSGetPurchaseRes
|
||||||
|
* @static
|
||||||
|
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns {string} The default type url
|
||||||
|
*/
|
||||||
|
CSGetPurchaseRes.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
||||||
|
if (typeUrlPrefix === undefined) {
|
||||||
|
typeUrlPrefix = "type.googleapis.com";
|
||||||
|
}
|
||||||
|
return typeUrlPrefix + "/cs.CSGetPurchaseRes";
|
||||||
|
};
|
||||||
|
|
||||||
|
return CSGetPurchaseRes;
|
||||||
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category enum.
|
* Category enum.
|
||||||
* @name cs.Category
|
* @name cs.Category
|
||||||
|
|||||||
+1
-1
Submodule proto_cs updated: 667f36bd33...984b9da404
Reference in New Issue
Block a user