Commit Graph

19 Commits

Author SHA1 Message Date
3bcaf0fbf3 实现游戏化宝箱奖励服务 2026-05-13 16:41:57 +08:00
18865e17ca 实现游戏化金币发放服务 2026-05-13 13:01:00 +08:00
1ad26d0fe8 补齐 XP 与连续学习测试覆盖 2026-05-13 10:55:17 +08:00
c08d3f75b9 实现每日首次进入红心补给 2026-05-13 10:53:27 +08:00
d71c45b2f1 实现连续学习里程碑奖励 2026-05-13 10:51:01 +08:00
447cef3dea 按挑战组完成更新连续学习 2026-05-13 10:47:46 +08:00
b5b3aaf3a7 实现游戏化 XP 来源与连对奖励 2026-05-13 10:26:21 +08:00
b590e60bce feat: implement non-linear 50-level XP curve (G2-1)
Replace flat 400 XP/level formula with the segmented curve from
LEVEL_RULES: Lv.1-5 steep ramp, Lv.6-10 moderate, Lv.11-20 linear +80,
Lv.21-35 +120, Lv.36-50 +180. Level 50 is hard-capped with xpToNextLevel=0.

Uses binary search over pre-computed cumulative thresholds for O(log n)
level lookup.
2026-05-12 11:04:23 +08:00
665efa4370 test: add comprehensive challenge group tests (G1-7)
Add 11 new test cases covering challenge session creation, correct/wrong
answers, idempotent duplicate submission, completion settlement, resource
exhaustion, Plus user bypass, and invalid input validation.

Refactor test helpers to use queue-based mockImplementation pattern for
more reliable db.select mocking across complex async flows.
2026-05-12 10:38:17 +08:00
05b9faa0ea feat: enforce daily high-reward session limits with tier-based quotas
Free users get 3 high-reward sessions/day, Plus users get 8. Sessions
after quota are still playable but with degraded XP rewards.
2026-05-12 00:01:31 +08:00
6ea5ed9de0 feat: add heart deduction boundaries with new user protection
Add 3-day new user heart protection (minimum 1 heart) and block
answering when hearts are exhausted for free-tier users.
2026-05-11 23:44:45 +08:00
9e0f97d162 Settle completed challenge sessions 2026-05-11 21:40:41 +08:00
5bb6ba29a2 Record idempotent challenge answers 2026-05-11 21:34:27 +08:00
1d84de8d15 Create challenge sessions with five questions 2026-05-11 18:32:40 +08:00
8382183ee5 Add gamification rule constants 2026-05-11 17:33:53 +08:00
3ea44189e8 Add Flutter app-facing API routes 2026-05-04 01:24:23 +08:00
2c97412c82 fix: 修复 admin-auth 测试的 TypeScript 类型错误
Some checks failed
CI/CD Pipeline / Code Quality (push) Successful in 18s
CI/CD Pipeline / Unit Tests (push) Failing after 14s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
将 mockDb 的类型从 Record<string, Mock> 改为显式的映射类型,
消除 CI 中 "possibly undefined" 的类型检查报错。
2026-04-23 12:55:01 +08:00
5b1f0848ac feat: 添加管理员修改自己密码的接口
Some checks failed
CI/CD Pipeline / Code Quality (push) Failing after 17s
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
新增 PUT /v1/admin/change-password 端点,允许已登录管理员
(admin / super_admin)修改自己的密码。需验证旧密码,
且新旧密码不能相同。错误由全局 errorHandler 统一处理。
2026-04-23 12:32:31 +08:00
b872b1cad9 feat: implement Phase 1b core features and Phase 1c commercialization
Phase 1b — Core Features:
- Huawei ID Kit login (token exchange + user info) with guest mode
- Quiz engine: randomized questions, distractor shuffling, answer verification
- XP service with combo bonuses (3/5/10-hit streaks), daily reset
- Streak service: >=3 correct/day, freeze, UTC date handling
- Hearts service: 5/day, 30min auto-restore, Pro unlimited
- 50 quiz questions across 3 categories (history/drama/crosstalk)
- 13 skill tree chapters with linear progression
- Idempotent seed import script (categories → skill tree → questions)
- 7 admin CRUD services (questions, categories, knowledge cards,
  skill tree, users, stats, feedback) with Zod validation
- All routes use Zod schema validation, /auth/me endpoint

Phase 1c — Commercialization:
- Leaderboard with live XP ranking, 10 tiers, weekly settlement
- Achievement system with 15 seed achievements and condition checking
- Huawei IAP receipt verification + subscription management
- Differentiated rate limiting (auth 10/min, quiz 60/min)
- Admin audit logging middleware

Infrastructure:
- Vitest test framework with DB mock utilities (19 tests passing)
- 12 DB tables (5 new: question_ratings, user_feedback, achievements,
  user_achievements, leaderboard_snapshots, subscriptions, admin_audit_log)
- TypeScript strict mode: zero errors
2026-04-09 00:12:12 +08:00