refactor: 拆分核心玩法模块并优化代码质量

将 WechatGame 单体模块拆分为独立的 User、Level、GameConfig 模块,
新增体力值系统、关卡闯关流程,并修复多项代码质量问题:
- 体力不足错误码从 401 修正为 400
- enterLevel 改用 findById 替代全表扫描
- consumeStamina 增加原子更新防止并发竞态
- 并行化独立数据库查询 (Promise.all)
- 移除 WechatGameService/Controller 死代码
This commit is contained in:
richarjiang
2026-04-10 09:07:50 +08:00
parent c775d5c6b0
commit fe2c13258e
33 changed files with 1681 additions and 978 deletions

View File

@@ -25,9 +25,13 @@ export class User {
@Column({ type: 'text', name: 'avatar_url', nullable: true })
avatarUrl!: string | null;
/** 积分(默认 10 */
@Column({ type: 'int', default: 10 })
points!: number;
/** 体力值(默认 5上限 5 */
@Column({ type: 'int', default: 5 })
stamina!: number;
/** 体力值最后更新时间(用于计算恢复) */
@Column({ type: 'timestamp', name: 'stamina_updated_at', nullable: true })
staminaUpdatedAt!: Date | null;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;