sdd_mvcp_contract_sample.json
2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"meta": {
"project": "REPLACE_PROJECT",
"version": "v0.1.0",
"effective_date": "REPLACE_DATE",
"owner": "REPLACE_OWNER"
},
"model_contract": [
{
"entity": "users",
"owner": "backend",
"purpose": "用户主数据",
"fields": [
{"name": "id", "type": "bigint", "nullable": false, "constraints": ["pk"]},
{"name": "tenant_id", "type": "bigint", "nullable": false, "constraints": ["fk:tenants.id", "idx"], "index": "idx"},
{"name": "status", "type": "varchar(20)", "nullable": false, "constraints": ["enum:DRAFT|ACTIVE|DISABLED"]}
]
}
],
"view_contract": [
{
"view_id": "v_user_list",
"route": "/users",
"fields": [
{"name": "keyword", "visible_when": "all", "validation": ["maxLen:128"], "required": false}
],
"events": [
{"event": "click_search", "target_controller_id": "c_users_search", "payload": {"filters": ["keyword"]}}
]
}
],
"controller_contract": [
{
"operation_id": "c_users_search",
"method": "GET",
"path": "/api/users",
"auth": "rbac:user:read",
"input": {"query": {"keyword": "string(optional)", "page": "int>=1"}},
"output": {"status": "ok", "items": "array", "total": "int"},
"idempotent": true,
"errors": [
{"code": "AUTH_DENIED", "retryable": false, "description": "未登录或权限不足"},
{"code": "INVALID_PARAM", "retryable": false, "description": "参数校验失败"}
]
}
],
"process_contract": [
{
"flow_id": "p_user_onboarding",
"start_state": "draft",
"end_state": "active",
"transitions": [
{"from": "draft", "to": "active", "trigger": "submit", "action": "c_user_create", "guard": "required_fields_ok", "error_state": "blocked", "retry_max": 1}
]
}
],
"acceptance_matrix": [
{
"requirement_id": "PRD-REQ-01",
"coverage": {
"model": ["users"],
"view": ["v_user_list"],
"controller": ["c_users_search"],
"process": ["p_user_onboarding"]
},
"acceptance_cases": [
{"type": "happy", "description": "列表可搜索并返回分页", "expected": "返回符合条件的用户"},
{"type": "boundary", "description": "keyword 超长", "expected": "返回 INVALID_PARAM"},
{"type": "failure", "description": "无权限", "expected": "返回 AUTH_DENIED"}
]
}
],
"non_goals": ["不处理企业微信绑定流程"],
"assumptions": [
{"id": "A-1", "statement": "用户表已有 tenant_id", "owner": "PO", "verification_plan": "对照历史仓库 schema", "status": "pending"}
],
"risks": [
{"id": "R-1", "description": "高并发查询导致超时", "impact": "high", "mitigation": "索引优化 + 异步分页缓存", "status": "pending"}
]
}