feat(share): 分享挑战关卡进度记录功能

- 新增 Level.timeLimit 字段支持关卡时间限制
- 新增 ShareLevelProgress 实体记录单关通关进度
- 新增 ShareLevelProgressRepository
- 新增 DTO: ReportLevelProgressDto, ReportLevelProgressResponseDto
- 新增 POST /v1/share/progress 接口用于上报进度
- 支持仅首次通关有效判断
- 支持时间限制内通关判断
- 不可变模式更新进度记录
- 数据库迁移脚本

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
richarjiang
2026-04-08 11:46:54 +08:00
parent 2dd22b10b1
commit 3d52cfe843
12 changed files with 960 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
Index,
Unique,
} from 'typeorm';
import { ShareParticipant } from './share-participant.entity';
import { Level } from '../../wechat-game/entities/level.entity';
@Entity('share_level_progress')
@Unique('uq_participant_level', ['participantId', 'levelId'])
export class ShareLevelProgress {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Index('idx_slp_participant_id')
@Column({ type: 'char', length: 36, name: 'participant_id' })
participantId!: string;
@ManyToOne(() => ShareParticipant)
@JoinColumn({ name: 'participant_id' })
participant!: ShareParticipant;
@Index('idx_slp_level_id')
@Column({ type: 'char', length: 191, name: 'level_id' })
levelId!: string;
@ManyToOne(() => Level)
@JoinColumn({ name: 'level_id' })
level!: Level;
@Column({ type: 'tinyint', width: 1, default: 0 })
passed!: boolean;
@Column({ type: 'int', default: 0, name: 'time_spent' })
timeSpent!: number;
@CreateDateColumn({ name: 'completed_at' })
completedAt!: Date;
}