docs(spec): 归档 error-code-registry + 同步错误码分段主 spec
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
062b314844
commit
28ecacdd42
@ -18,11 +18,19 @@
|
||||
- **THEN** 返回非 0 code 与可读 message,data 为空
|
||||
|
||||
### Requirement: 错误码分段
|
||||
错误码 SHALL 与 HTTP 状态对齐分段:401xx 认证、403xx 授权、400xx 参数、404xx 资源、409xx 冲突、500xx 系统。
|
||||
错误码 SHALL 采用「业务域 + 错误序」分段:5 位数字 `[域码 2 位][序 3 位]`,域码集中登记于 `error-codes` 注册表(00 通用、10 认证、11 用户、12 角色、13 资源、14 组织、15 租户、16 字典、17 配置、20 会话、21 通知…);HTTP 状态仍按语义返回(400/401/403/404/409/500),`code` 为业务码。
|
||||
|
||||
#### Scenario: 未登录
|
||||
- **WHEN** 未携带有效 token 访问受保护接口
|
||||
- **THEN** HTTP 401,code 为 401xx 段
|
||||
- **THEN** HTTP 401,code 为认证域业务码(如 10002),无业务码时回退 40100
|
||||
|
||||
#### Scenario: 业务错误码
|
||||
- **WHEN** 业务处理失败(如用户名已存在)
|
||||
- **THEN** 返回对应 HTTP 状态 + 注册表内的业务码与可读 message
|
||||
|
||||
#### Scenario: 系统错误兜底
|
||||
- **WHEN** 非业务异常(框架/未知错误)
|
||||
- **THEN** code 回退为 HTTP 状态 ×100
|
||||
|
||||
### Requirement: 分页约定
|
||||
列表接口 SHALL 使用 page/pageSize 分页,返回 `{ list, total, page, pageSize }`。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user