|
|
@@ -0,0 +1,48 @@
|
|
|
+# S-cfc-330 - child.badge.view 实现使绿验证报告 (2026-11-14)
|
|
|
+
|
|
|
+**能力键**: `child.badge.view`
|
|
|
+**任务号**: S-cfc-330(TDD 实现使绿派发 · requeue#1 —— 上一轮「done 但无 git 证据」,本轮产出证据闭环;SC-C-09 勋章墙 / SC-C-10 勋章解锁提醒)
|
|
|
+**状态**: TDD-GREEN(测试 11/11 全绿;实现已在链,无需 src/main 改动 —— O-22 豁免,同 S-cfc-309 / S-cfc-328 先例)
|
|
|
+**状态机流转**: RED(契约) -> GREEN(经本验证提交转测试侧 mark-green 收尾)
|
|
|
+
|
|
|
+## 验证摘要
|
|
|
+
|
|
|
+1. **契约测试**: `ChildBadgeViewContractTest`(`cfc-backend/src/test/java/com/etotem/cfc/unit/`,11 cases;测试侧登记 commit `026e3b58e` 已推送 origin/cfclub)在 `origin/cfclub` HEAD 实测 **11/11 Green**。
|
|
|
+2. **实现校验**: 能力链已在 `origin/cfclub` 完整落地(实现来源 commit `36b671565` feat(badge,user): C-10勋章解锁站内通知)——
|
|
|
+ - `BadgeService.getActiveBadges()`:勋章墙底图,`is_active=1` 过滤 + `ORDER BY sort_order ASC`(契约断言 is_active / sort_order 升序 ✓);
|
|
|
+ - `getActiveMemberBadges(memberId)`:按成员(`child_badge.child_id`)过滤 + `status=1` + `is_favorite DESC` + `earned_at DESC`(契约断言四段 SQL ✓);
|
|
|
+ - `getBadgeById(id)`:返回达成条件字段 triggerType/threshold/description ✓;
|
|
|
+ - `getMemberBadgeStats(memberId)`:total/active(status=1)/expired(status=0)/revoked(status=-1) 四态计数 + `selectCategoryStats`/`selectLevelStats` 分类统计 ✓;
|
|
|
+ - `getFamilyRanking(familyId)`:`memberBadgeMapper.selectFamilyRanking(familyId)` 按家庭排行 ✓;
|
|
|
+ - `toggleFavorite(memberId, badgeId)`:selectOne 定位 → isFavorite 翻转 → updateById(幂等,未命中不写)✓;
|
|
|
+ - `grantBadge(memberId, badgeId)`:判重(已拥有直接 return,不写库不推送)→ 勋章不存在抛 `RuntimeException("勋章不存在")` → 写 MemberBadge 且 `expireDays` 时写 `expireAt` → `sendBadgeUnlockNotice`;站内通知 `notificationDispatchService.sendByTemplate("badge_unlock", targetUserId, vars("badgeName", ...), "badge", badgeId, "勋章解锁", ...)`;
|
|
|
+ - `sendBadgeUnlockNotice`:可登录成员(userId 非空)→ 通知本人;不可登录成员(userId 空)→ `familyMemberMapper.selectOne` 按 `ORDER BY (is_admin=1) DESC, id ASC LIMIT 1` 找管理员代收;通知失败不阻断授予 ✓。
|
|
|
+3. **测试结果**: 目标类 **11/11**;关联链 BadgeControllerGetMemberBadgesTest 9/9 + AdminBadgeManageContractTest 11/11 + BadgeServiceUnlockNoticeTest 6/6,合计 **37/37 全绿**,BUILD SUCCESS。
|
|
|
+
|
|
|
+## 结论
|
|
|
+
|
|
|
+`child.badge.view` 契约测试在基线即全绿:该键实现已存在于 `origin/cfclub`(契约登记时即实测全绿,见 `docs/tdd/orchestration/report-dev-2026-11-14-0837.md` 第 64 行「11 用例全绿=实现已存在(O-22 豁免)」)。**无需代码修改**即可使红单测全部转绿,按任务约定「若实测意外全绿,交编排侧核实能力键状态(转测试登记),不私改 src/main 实现」。本提交为 docs-only 闭环验证产物(补齐 requeue#1 所需 git 证据),交编排侧转测试侧 mark-green 收尾。
|
|
|
+
|
|
|
+## 暴露的缺陷
|
|
|
+
|
|
|
+无阻断性缺陷。仅一处低优先级观察(不影响契约绿):`MemberBadge` 实体字段 `memberId` 通过 `@TableField("child_id")` 映射到遗留表 `child_badge` 的 `child_id` 列,与项目「统一 memberId 口径、新功能禁止新增 childId 引用」的规范存在命名历史债(表与列名沿用 child 时期命名),属既定现状,非本键引入,不建议在本任务范围内改动。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 实现会话实跑复核(2026-11-14,派发会话,任务 S-cfc-330)
|
|
|
+
|
|
|
+**基准**: `origin/cfclub` @ `64c505adb`(worktree `.worktrees/task_S-cfc-330`,分支 `task/S-cfc-330`,ff 至 origin/cfclub,无工作区改动)
|
|
|
+
|
|
|
+**复核命令**(cfc-backend 单模块,未触碰测试/未改实现):
|
|
|
+```
|
|
|
+mvn -q -Dtest=ChildBadgeViewContractTest -DfailIfNoTests=false test
|
|
|
+mvn -q -Dtest='ChildBadgeViewContractTest,BadgeControllerGetMemberBadgesTest,BadgeServiceUnlockNoticeTest,AdminBadgeManageContractTest' -DfailIfNoTests=false test
|
|
|
+```
|
|
|
+
|
|
|
+**实测结果**(surefire reports):
|
|
|
+```
|
|
|
+Tests run: 11, Failures: 0, Errors: 0, Skipped: 0 - in com.etotem.cfc.unit.ChildBadgeViewContractTest
|
|
|
+Tests run: 9, Failures: 0, Errors: 0, Skipped: 0 - in com.etotem.cfc.controller.BadgeControllerGetMemberBadgesTest
|
|
|
+Tests run: 11, Failures: 0, Errors: 0, Skipped: 0 - in com.etotem.cfc.unit.AdminBadgeManageContractTest
|
|
|
+Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 - in com.etotem.cfc.unit.BadgeServiceUnlockNoticeTest
|
|
|
+```
|