feat: 支持新的关卡数据结构

This commit is contained in:
richarjiang
2026-04-19 13:27:10 +08:00
parent 1d6cd0cdc0
commit e6079e4345
33 changed files with 882 additions and 2843 deletions

View File

@@ -8,6 +8,7 @@ import { ShareConfigRepository } from './repositories/share-config.repository';
import { ShareParticipantRepository } from './repositories/share-participant.repository';
import { ShareLevelProgressRepository } from './repositories/share-level-progress.repository';
import { LevelRepository } from '../wechat-game/repositories/level.repository';
import { pickLevelImageFields } from '../wechat-game/level-fields.helper';
import { CreateShareDto } from './dto/create-share.dto';
import { ReportLevelProgressDto } from './dto/report-level-progress.dto';
import {
@@ -83,7 +84,7 @@ export class ShareService {
await this.shareParticipantRepository.addParticipant(config.id, userId);
}
// 单次查询获取所有关卡,再按 levelIds 顺序排列
// Single query, then reorder to match levelIds sequence
const allLevels = await this.levelRepository.findByIds(config.levelIds);
const levelMap = new Map(allLevels.map((l) => [l.id, l]));
@@ -95,11 +96,8 @@ export class ShareService {
return {
id: level.id,
level: index + 1,
imageUrl: level.imageUrl,
...pickLevelImageFields(level),
answer: level.answer,
hint1: level.hint1,
hint2: level.hint2,
hint3: level.hint3,
sortOrder: level.sortOrder,
};
});