修改:协议和配置表
This commit is contained in:
@@ -15,50 +15,66 @@ export class MockGirlService implements IGirlService {
|
||||
return ({ code: 100, error: { message } } as unknown) as ApiResponse<T>;
|
||||
}
|
||||
|
||||
private genBrief(id: number, name: string, age: number, tagKey: string, priceType: number, price: number, avatar: string, star: number, category: number, listAvatarPath: string): proto.cs.IGirlBrief {
|
||||
private genBrief(id: number, nameKey: string, age: string, category: number, tagKey: string, priceType: number, price: number, vipUnlock: number, avatarPath: string, listAvatarPath: string): proto.cs.IGirls {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
nameKey,
|
||||
age,
|
||||
category,
|
||||
tagKey,
|
||||
priceType,
|
||||
price,
|
||||
avatar,
|
||||
star,
|
||||
category,
|
||||
vipUnlock,
|
||||
avatarPath,
|
||||
listAvatarPath,
|
||||
};
|
||||
}
|
||||
|
||||
private genPhoto(imageType: number, imagePrice: number, path: string, isRelease: boolean, ): proto.cs.IPurchaseCommercialImage {
|
||||
private genPhoto(id: number, imageType: number, unlockCounts: number, imagePrice: number, path: string): proto.cs.IPurchaseCommercialImage {
|
||||
return {
|
||||
id,
|
||||
imageType,
|
||||
unlockCounts,
|
||||
imagePrice,
|
||||
path,
|
||||
isRelease,
|
||||
};
|
||||
}
|
||||
|
||||
private genVideo(path: string, emotion: number, videoPrice: number, isRelease: boolean): proto.cs.IPurchaseCommercialVideo {
|
||||
return {
|
||||
private genVideo(id: number, path: string, emotion: number, videoPrice: number): proto.cs.IPurchaseCommercialVideo {
|
||||
return {
|
||||
id,
|
||||
path,
|
||||
emotion,
|
||||
videoPrice,
|
||||
isRelease,
|
||||
};
|
||||
}
|
||||
|
||||
private genDetail(brief: proto.cs.IGirlBrief, desc: string, images: proto.cs.IPurchaseCommercialImage[], videos: proto.cs.IPurchaseCommercialVideo[], isRelease: boolean, chatCount: number): proto.cs.IGirlDetail {
|
||||
private genDetail(id: number, detailDesc: string, commercialImages: proto.cs.IPurchaseCommercialImage[], commercialVideos: proto.cs.IPurchaseCommercialVideo[]): proto.cs.IGirlsDetail {
|
||||
return {
|
||||
brief,
|
||||
desc,
|
||||
images,
|
||||
videos,
|
||||
isRelease,
|
||||
chatCount,
|
||||
id,
|
||||
detailDesc,
|
||||
commercialImages,
|
||||
commercialVideos,
|
||||
};
|
||||
}
|
||||
|
||||
private genGirlData(
|
||||
id: number, girl: proto.cs.IGirls, isRelease: boolean, star: number,
|
||||
detail: proto.cs.IGirlsDetail, images: proto.cs.IResourceUnlock[], videos: proto.cs.IResourceUnlock[],
|
||||
chatTotalCount: number, chatRemainCount: number): proto.cs.IGirlData {
|
||||
return {
|
||||
id,
|
||||
girl,
|
||||
isRelease,
|
||||
star,
|
||||
detail,
|
||||
images,
|
||||
videos,
|
||||
chatTotalCount,
|
||||
chatRemainCount,
|
||||
};
|
||||
}
|
||||
|
||||
// 每日推荐
|
||||
async reqDailyRecommend(_req: proto.cs.ICSDailyRecommendReq): Promise<ApiResponse<proto.cs.ICSDailyRecommendRes>> {
|
||||
// 延时
|
||||
@@ -67,19 +83,19 @@ export class MockGirlService implements IGirlService {
|
||||
const configData = ConfigManager.I.getDataById<GirlConfig>(ConfigId.Girl);
|
||||
const allId = configData.getAllId();
|
||||
const recId = allId[0];
|
||||
let name = configData.getNameById(recId);
|
||||
let age = Number(configData.getAgeById(recId));
|
||||
let nameKey = configData.getNameById(recId);
|
||||
let age = configData.getAgeById(recId);
|
||||
let tagKey = configData.getTagKeyById(recId);
|
||||
let priceType = configData.getPriceTypeById(recId);
|
||||
let price = 9.9;
|
||||
let avatar = configData.getAvatarPathById(recId);
|
||||
let star = 3;
|
||||
let price = configData.getPriceById(recId);
|
||||
let vipUnlock = configData.getVipUnlockById(recId);
|
||||
let avatarPath = configData.getAvatarPathById(recId);
|
||||
let category = configData.getCategoryById(recId);
|
||||
let listAvatarPath = configData.getListAvatarPathPathById(recId);
|
||||
let oneData = this.genBrief(recId, name, age, tagKey, priceType, price, avatar, star, category, listAvatarPath);
|
||||
let oneData = this.genBrief(recId, nameKey, age, category, tagKey, priceType, price, vipUnlock, avatarPath, listAvatarPath);
|
||||
// 返回数据
|
||||
const girls = [oneData];
|
||||
return this.ok({ girls });
|
||||
const res: proto.cs.ICSDailyRecommendRes = {girl: oneData};
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
// 获取技师列表
|
||||
@@ -105,29 +121,35 @@ export class MockGirlService implements IGirlService {
|
||||
const start = (page - 1) * limit;
|
||||
const pageIds = filteredIds.slice(start, start + limit);
|
||||
|
||||
// 映射为 IGirlBrief
|
||||
const girls: proto.cs.IGirlBrief[] = pageIds.map((id: number) => {
|
||||
const name = configData.getNameById(id);
|
||||
const age = Number(configData.getAgeById(id));
|
||||
// 映射数据
|
||||
const girls: proto.cs.IGirlData[] = pageIds.map((id: number) => {
|
||||
// 简要数据
|
||||
const nameKey = configData.getNameById(id);
|
||||
const age = configData.getAgeById(id);
|
||||
const tagKey = configData.getTagKeyById(id);
|
||||
const priceType = Number(configData.getPriceTypeById(id));
|
||||
const avatar = configData.getAvatarPathById(id);
|
||||
|
||||
// 如果有价格配置,就用配置里的,否则给个兜底值
|
||||
const price = typeof (configData as any).getPriceById === "function"
|
||||
? Number((configData as any).getPriceById(id) ?? 9.9)
|
||||
: 9.9;
|
||||
|
||||
// 星级兜底:1~5
|
||||
const star = (id % 5) + 1;
|
||||
|
||||
const priceType = configData.getPriceTypeById(id);
|
||||
const price = configData.getPriceById(id);
|
||||
const vipUnlock = configData.getVipUnlockById(id);
|
||||
const avatarPath = configData.getAvatarPathById(id);
|
||||
const category = configData.getCategoryById(id);
|
||||
const listAvatarPath = configData.getListAvatarPathPathById(id);
|
||||
|
||||
return this.genBrief(id, name, age, tagKey, priceType, price, avatar, star, category, listAvatarPath);
|
||||
const listAvatarPath = configData.getListAvatarPathPathById(id);
|
||||
const briefData = this.genBrief(id, nameKey, age, category, tagKey, priceType, price, vipUnlock, avatarPath, listAvatarPath);
|
||||
|
||||
const isRelease = true;
|
||||
const star = 3;
|
||||
// 详细数据
|
||||
const detail = null;
|
||||
const images = [];
|
||||
const videos = [];
|
||||
const chatTotalCount = 0;
|
||||
const chatRemainCount = 0;
|
||||
const girlData = this.genGirlData(id, briefData, isRelease, star, detail, images, videos, chatTotalCount, chatRemainCount);
|
||||
|
||||
return girlData;
|
||||
});
|
||||
// 返回数据
|
||||
return this.ok({ girls });
|
||||
const res: proto.cs.ICSGetGirlListRes = {girls};
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
// 获取技师详细信息
|
||||
@@ -140,45 +162,76 @@ export class MockGirlService implements IGirlService {
|
||||
// id
|
||||
const girlId = req.id;
|
||||
// 简要数据
|
||||
let name = girlConfig.getNameById(girlId);
|
||||
let age = Number(girlConfig.getAgeById(girlId));
|
||||
let nameKey = girlConfig.getNameById(girlId);
|
||||
let age = girlConfig.getAgeById(girlId);
|
||||
let tagKey = girlConfig.getTagKeyById(girlId);
|
||||
let priceType = girlConfig.getPriceTypeById(girlId);
|
||||
let price = 9.9;
|
||||
let avatar = girlConfig.getAvatarPathById(girlId);
|
||||
let star = 3;
|
||||
let price = girlConfig.getPriceById(girlId);
|
||||
let vipUnlock = girlConfig.getVipUnlockById(girlId);
|
||||
let avatarPath = girlConfig.getAvatarPathById(girlId);
|
||||
let category = girlConfig.getCategoryById(girlId);
|
||||
let listAvatarPath = girlConfig.getListAvatarPathPathById(girlId);
|
||||
let briefData = this.genBrief(girlId, name, age, tagKey, priceType, price, avatar, star, category, listAvatarPath);
|
||||
let briefData = this.genBrief(girlId, nameKey, age, category, tagKey, priceType, price, vipUnlock, avatarPath, listAvatarPath);
|
||||
|
||||
let desc = girlDetailConfig.getDetailDescById(girlId);
|
||||
let isRelease = Math.random() < 0.4;
|
||||
let chatCount = 10;
|
||||
let detailDesc = girlDetailConfig.getDetailDescById(girlId);
|
||||
// 图片
|
||||
let photoData = [];
|
||||
let photoCount = girlDetailConfig.getCommercialImagesCount(girlId);
|
||||
for (let i = 0; i < photoCount; i++) {
|
||||
let imageType = girlDetailConfig.getImageTypeById(girlId, i);
|
||||
let imagePath = girlDetailConfig.getImagePathById(girlId, i);
|
||||
let isRelease = Math.random() < 0.4;
|
||||
let imagePrice = girlDetailConfig.getImagePriceById(girlId, i);
|
||||
let oneData = this.genPhoto(imageType, imagePrice, imagePath, isRelease);
|
||||
let photoIds = girlDetailConfig.getCommercialImagesIds(girlId);
|
||||
for (let id of photoIds) {
|
||||
let imageType = girlDetailConfig.getImageTypeById(girlId, id);
|
||||
let unlockCounts = girlDetailConfig.getImageUnlockCountsById(girlId, id);
|
||||
let imagePrice = girlDetailConfig.getImagePriceById(girlId, id);
|
||||
let imagePath = girlDetailConfig.getImagePathById(girlId, id);
|
||||
let oneData = this.genPhoto(id, imageType, unlockCounts, imagePrice, imagePath);
|
||||
photoData.push(oneData);
|
||||
}
|
||||
// 视频
|
||||
let videoData = [];
|
||||
let videoCount = girlDetailConfig.getCommercialVideosCount(girlId);
|
||||
for (let i = 0; i < videoCount; i++) {
|
||||
let videoPath = girlDetailConfig.getVideoPathById(girlId, i);
|
||||
let videoEmotion = girlDetailConfig.getVideoEmotionById(girlId, i);
|
||||
let videoPrice = girlDetailConfig.getVideoPriceById(girlId, i);
|
||||
let isRelease = Math.random() < 0.4;
|
||||
let oneData = this.genVideo(videoPath, videoEmotion, videoPrice, isRelease);
|
||||
let videoIds = girlDetailConfig.getCommercialVideosIds(girlId);
|
||||
for (let id of videoIds) {
|
||||
let videoPath = girlDetailConfig.getVideoPathById(girlId, id);
|
||||
let videoEmotion = girlDetailConfig.getVideoEmotionById(girlId, id);
|
||||
let videoPrice = girlDetailConfig.getVideoPriceById(girlId, id);
|
||||
let oneData = this.genVideo(id, videoPath, videoEmotion, videoPrice);
|
||||
videoData.push(oneData);
|
||||
}
|
||||
// 详细数据
|
||||
let detail = this.genDetail(briefData, desc, photoData, videoData, isRelease, chatCount);
|
||||
let detail = this.genDetail(girlId, detailDesc, photoData, videoData);
|
||||
// 图片解锁数据
|
||||
let unlockImageData: proto.cs.IResourceUnlock[] = [];
|
||||
for (let id of photoIds) {
|
||||
// 偶数才解锁
|
||||
let isUnlock = (id % 2 === 0);
|
||||
if (isUnlock) {
|
||||
let oneData = {
|
||||
girlId: girlId,
|
||||
resId: id,
|
||||
};
|
||||
unlockImageData.push(oneData);
|
||||
}
|
||||
}
|
||||
// 视频解锁数据
|
||||
let unlockVideoData: proto.cs.IResourceUnlock[] = [];
|
||||
for (let id of videoIds) {
|
||||
// 偶数才解锁
|
||||
let isUnlock = (id % 2 === 0);
|
||||
if (isUnlock) {
|
||||
let oneData = {
|
||||
girlId: girlId,
|
||||
resId: id,
|
||||
};
|
||||
unlockVideoData.push(oneData);
|
||||
}
|
||||
}
|
||||
|
||||
const star = 3;
|
||||
const chatTotalCount = 10;
|
||||
const chatRemainCount = 10;
|
||||
|
||||
const girlData = this.genGirlData(girlId, briefData, isRelease, star, detail, unlockImageData, unlockVideoData, chatTotalCount, chatRemainCount);
|
||||
// 返回数据
|
||||
return this.ok({ detail });
|
||||
const res: proto.cs.ICSGetGirlDetailRes = {girl: girlData};
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user