refactor: 拆分核心玩法模块并优化代码质量
将 WechatGame 单体模块拆分为独立的 User、Level、GameConfig 模块, 新增体力值系统、关卡闯关流程,并修复多项代码质量问题: - 体力不足错误码从 401 修正为 400 - enterLevel 改用 findById 替代全表扫描 - consumeStamina 增加原子更新防止并发竞态 - 并行化独立数据库查询 (Promise.all) - 移除 WechatGameService/Controller 死代码
This commit is contained in:
38
src/modules/level/dto/level-list.dto.ts
Normal file
38
src/modules/level/dto/level-list.dto.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class LevelListItemDto {
|
||||
@ApiProperty({ description: '关卡 ID' })
|
||||
id!: string;
|
||||
|
||||
@ApiProperty({ description: '关卡编号' })
|
||||
level!: number;
|
||||
|
||||
@ApiProperty({ description: '图片 URL' })
|
||||
imageUrl!: string;
|
||||
|
||||
@ApiProperty({ description: '答案(仅已通关时返回)', nullable: true })
|
||||
answer!: string | null;
|
||||
|
||||
@ApiProperty({ description: '线索1(仅已通关时返回)', nullable: true })
|
||||
hint1!: string | null;
|
||||
|
||||
@ApiProperty({ description: '线索2(仅已通关时返回)', nullable: true })
|
||||
hint2!: string | null;
|
||||
|
||||
@ApiProperty({ description: '线索3(仅已通关时返回)', nullable: true })
|
||||
hint3!: string | null;
|
||||
|
||||
@ApiProperty({ description: '是否已通关' })
|
||||
completed!: boolean;
|
||||
|
||||
@ApiProperty({ description: '通关时长(秒),未通关时为 null', nullable: true })
|
||||
timeSpent!: number | null;
|
||||
}
|
||||
|
||||
export class LevelListResponseDto {
|
||||
@ApiProperty({ type: [LevelListItemDto], description: '关卡列表' })
|
||||
levels!: LevelListItemDto[];
|
||||
|
||||
@ApiProperty({ description: '关卡总数' })
|
||||
total!: number;
|
||||
}
|
||||
Reference in New Issue
Block a user