File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 27
27
- [ 服务器目录如何规划?] (服务器目录如何规划.md)
28
28
- [ 如何规划日志文件和格式?] (如何规划日志文件和格式.md)
29
29
- [ 接口请求参数如何定义?] (接口请求参数如何定义.md)
30
- - 接口返回数据结构以及状态码如何定义?
31
- - 微服务接口如何优雅的暴露给前端进行调用?
32
- - 在微服务体系中,如何优雅的使用接口文档和前端进行联调?
30
+ - [ 接口返回数据结构以及状态码如何定义?] (接口返回数据结构以及状态码如何定义.md)
31
+ - 如何优雅的使用接口文档?
33
32
- 如何优雅的进行服务更新发布?
34
33
- 服务注册组件如何选择?
35
34
- 如何优雅的使用配置中心?
36
35
- 多个节点定时任务如何设置?
37
36
- 网关应该承担什么功能和能力?
37
+ - 微服务接口如何优雅的暴露给前端进行调用?
38
38
- 微服务体系中,后台管理平台如何规划?
39
39
40
40
Original file line number Diff line number Diff line change
1
+ ### 数据返回格式
2
+ - 正常返回
3
+ - ` applicaiton/json ` 格式进行返回数据
4
+ - ` data ` 具体的业务数据
5
+ - ` http status code ` 为200
6
+ - ` traceId ` 为唯一的请求id
7
+ - 业务逻辑异常,为了统一返回的数据结构,统一使用了[ zalando/problem] ( https://github.com/zalando/problem ) 项目作为返回的数据结构。主要包括:
8
+ - 定义统一的业务异常类,然后统一捕获该异常类,然后转换数据结构。
9
+ - ` applicaiton/json ` 格式进行返回数据
10
+ - ` detail ` 为对应的错误信息简单描述
11
+ - ` code ` 为对应的业务错误码
12
+ - ` type ` 为异常请求的uri
13
+ - ` http status code ` 为200
14
+ - ` traceId ` 为唯一的请求id
15
+ - 请求异常,统一识别异常类型,然后转换数据结构
16
+ - ` applicaiton/json ` 格式进行返回数据
17
+ - ` detail ` 为对应的错误信息简单描述
18
+ - ` code ` 为对应的业务错误码
19
+ - ` type ` 为异常请求的uri
20
+ - ` http status code ` 为400、401、403、404、405、406、415
21
+ - ` traceId ` 为唯一的请求id
22
+ - 非业务异常类,统一处理
23
+ - ` applicaiton/json ` 格式进行返回数据
24
+ - ` detail ` 为对应的错误信息简单描述
25
+ - ` code ` 为对应的错误码
26
+ - ` type ` 为异常请求的uri
27
+ - ` http status code ` 为500、501
28
+ - ` traceId ` 为唯一的请求id
29
+
30
+ ### 统一异常捕获
31
+ - 通过继承[ zalando/problem-spring-web] ( https://github.com/zalando/problem-spring-web ) 项目的` ProblemHandling ` 类
32
+ - 通过使用` @RestControllerAdvice ` 来统一捕获异常
33
+ - 额外定义业务异常类的统一处理方法
34
+ - 通过使用` ResponseBodyAdvice ` 接口和` @RestControllerAdvice ` 来统一添加traceId和请求的uri
You can’t perform that action at this time.
0 commit comments