refactor: 拆分核心玩法模块并优化代码质量
将 WechatGame 单体模块拆分为独立的 User、Level、GameConfig 模块, 新增体力值系统、关卡闯关流程,并修复多项代码质量问题: - 体力不足错误码从 401 修正为 400 - enterLevel 改用 findById 替代全表扫描 - consumeStamina 增加原子更新防止并发竞态 - 并行化独立数据库查询 (Promise.all) - 移除 WechatGameService/Controller 死代码
This commit is contained in:
34
src/modules/user/dto/user-profile.dto.ts
Normal file
34
src/modules/user/dto/user-profile.dto.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class StaminaInfoDto {
|
||||
@ApiProperty({ description: '当前体力值' })
|
||||
current!: number;
|
||||
|
||||
@ApiProperty({ description: '体力值上限' })
|
||||
max!: number;
|
||||
|
||||
@ApiProperty({ description: '下次恢复时间(ISO 字符串),满体力时为 null', nullable: true })
|
||||
nextRecoverAt!: string | null;
|
||||
}
|
||||
|
||||
export class UserProfileResponseDto {
|
||||
@ApiProperty({ description: '用户 ID' })
|
||||
id!: string;
|
||||
|
||||
@ApiProperty({ description: '用户昵称', nullable: true })
|
||||
nickname!: string | null;
|
||||
|
||||
@ApiProperty({ description: '体力信息' })
|
||||
stamina!: StaminaInfoDto;
|
||||
}
|
||||
|
||||
export class GameDataResponseDto {
|
||||
@ApiProperty({ description: '用户信息' })
|
||||
user!: {
|
||||
id: string;
|
||||
stamina: StaminaInfoDto;
|
||||
};
|
||||
|
||||
@ApiProperty({ description: '已完成的关卡 ID 列表' })
|
||||
completedLevelIds!: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user