feat(ECR-018): Entitlement 用户权益只读并 Closed

聚合 GET /admin/users/:id/entitlements(Membership∪DeepAccess∪问答额度)与 admin-h5 权益 Tab;无 migration / 无真支付。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-07 19:26:15 +08:00
co-authored by Cursor
parent 37b91e51b8
commit c81f57a7d1
28 changed files with 597 additions and 12 deletions
@@ -0,0 +1,24 @@
# Backend Design: ECR-018 Entitlement
| ID | BD-2026-018 |
| Status | Approved |
| Coding | Loop authorized |
| Level | L2 |
| Migration | NO |
## Backend Change Boundary
```text
Domain: Entitlement read model (Membership DeepAccess ask quotas)
App: AdminHandler → admin.Service → AdminRepo + ReportRepo.GetMembership
API: GET /api/v1/admin/users/{id}/entitlements
Permission: admin.users.read
Migration: NO
UI: admin-h5 UserDetail「权益」Tab
```
## Out of boundary
Payment gateway · new entitlement matrix table · order mutation · UGC
Rollback: remove route + UI tab(无 schema
+1
View File
@@ -2,6 +2,7 @@
## 2026-08-07
- **ECR-018 Closed**Entitlement`GET /admin/users/:id/entitlements` · admin-h5 权益 Tab · Migration NO
- **ECR-017 Closed**AskOperationsAskSessionView 只读 · `admin.ask.read` · admin-h5 `/ask` · migration 000019
- **ECR-016 Closed**UserIntelligence`GET /admin/users/:id/insight` 只读聚合 · admin-h5 洞察 Tab · Migration NO
- **ECR-015 Closed**RedemptionCode(批次生成 · C端兑码 · 作废 · 审计)
+9
View File
@@ -0,0 +1,9 @@
# CODE_REVIEW — ECR-018
**Verdict:** Approve → Closed
Date: 2026-08-07 · Loop continuous
- Additive Entitlement 读模型;Migration NO
- Handler → Service → Repository;无真支付/UGC
- Integration AC mapped · OpenAPI updated
+17
View File
@@ -0,0 +1,17 @@
ecr: ECR-018
capability: CommerceEntitlement
bounded_context: Membership_Orders
parent: WAVE0-FROZEN
predecessor: ECR-017
change:
type: additive
breaking_change: false
migration_required: false
compatibility_notes: >
Additive read API GET /admin/users/{id}/entitlements.
Aggregates memberships + deep_accesses + ask quotas; no schema change.
apis:
- method: GET
path: /api/v1/admin/users/{id}/entitlements
change: added
+19
View File
@@ -0,0 +1,19 @@
# ECR-018
**Title:** Entitlement(用户权益只读薄切片)
**Status:** **Closed**
**Closed:** 2026-08-07Loop continuous
**Parent:** WAVE0-FROZEN · **Predecessor:** ECR-017 Closed
**Change Level:** L2
## Change
`GET /admin/users/:id/entitlements` 聚合 Membership/DeepAccess/问答额度;admin-h5 用户详情「权益」区。
## Forbidden
真支付 · 新权益表 · 改订单 · UGC
## Linked
Spec `ops-entitlement.md` · BD-2026-018 · CONTRACT_DIFF/ECR-018.yaml · TEST_REPORT/ECR-018.md
@@ -0,0 +1,8 @@
# ENGINEERING_SPEC — ECR-018
1. Repo DeepAccess 列表 + Entitlement 聚合
2. GET /users/:id/entitlements + OpenAPI
3. admin-h5 用户详情「权益」Tab
4. Integration · Closed
Migration: **NO**
@@ -0,0 +1,3 @@
# HANDOFF — ECR-018 Architect → Engineer
Loop continuous · Approved + Coding. Migration NO. Forbidden: 真支付/UGC/改订单.
@@ -0,0 +1,3 @@
# HANDOFF — ECR-018 Engineer → Reviewer
TestUserEntitlements PASS · 权益 Tab · Ready for Closed.
+3
View File
@@ -0,0 +1,3 @@
# PRODUCT_SPEC — ECR-018
对齐 ops-entitlement.md · Approved · Loop · L2 · Entitlement 只读聚合
+6
View File
@@ -0,0 +1,6 @@
# STATE — ECR-018
| Status | **Closed** |
| Phase | closed |
| Spec | ops-entitlement.md |
| Updated | 2026-08-07 |
+11
View File
@@ -0,0 +1,11 @@
id: TASK-018-ECR018
ecr: ECR-018
title: Entitlement implement
role: engineer
status: closed
change_level: L2
parent: WAVE0-FROZEN
predecessor: ECR-017
acceptance:
- Spec AC mapped
- No migration / no payment / no UGC
+31
View File
@@ -0,0 +1,31 @@
# TEST_REPORT — ECR-018 Entitlement
Date: 2026-08-07 · Loop continuous · commit: (pending)
## Commands
```bash
cd apps/api && go test ./internal/integration/ -run TestUserEntitlements -count=1
npm run build:admin
python3 scripts/ess-validate.py --phase review --ecr ECR-018
python3 scripts/ess-gate-check.py --ecr ECR-018
```
## Results
| Check | Result |
|-------|--------|
| TestUserEntitlements | PASS |
| build:admin | PASS |
| ess-validate review | PASS |
## AC
| ID | Evidence |
|----|----------|
| AC-F-01 | grant 后 flags.report_detail_via_membership=true |
| AC-F-02 | deep_access pay-mock 后 count≥1 |
| AC-F-03 | (空权益仍 200,覆盖于无会员前置态) |
| AC-S-01 | 无 token → 401 |
| AC-P-01 | GET &lt; 500ms |
| AC-O-01 | N/A 只读 |
+1
View File
@@ -22,3 +22,4 @@
| ECR-014 | MembershipPlan | **Closed** | Spec ops-membership-plan · BD-2026-014 · TEST_REPORT · Loop continuous |
| ECR-016 | UserIntelligence | **Closed** | Spec ops-user-intelligence · BD-2026-016 · TEST_REPORT · CODE_REVIEW · Loop continuous |
| ECR-017 | AskOperations | **Closed** | Spec ops-ask-operations · BD-2026-017 · migration 000019 · TEST_REPORT · CODE_REVIEW · Loop continuous |
| ECR-018 | Entitlement | **Closed** | Spec ops-entitlement · BD-2026-018 · TEST_REPORT · CODE_REVIEW · Loop continuous |
+1 -1
View File
@@ -30,4 +30,4 @@ Human 明文:**直接用 Loop,不用人工确认。**
| Done | Next |
|------|------|
| ECR-013A/B/014/015/016/017 Closed | **ECR-018** Entitlement 细权薄切片(或 ContentSafety);禁真支付/UGC |
| ECR-013A/B/014/015/016/017/018 Closed | **ECR-019** ContentSafety 薄切片(FilterRule 只读优先);禁真支付/UGC |