Commit 1e73d049 by 李秋伟

Update README.md

parent bf9a96a8
...@@ -5,7 +5,28 @@ ...@@ -5,7 +5,28 @@
- 支持dubbo、http协议swagger文档 - 支持dubbo、http协议swagger文档
- 支持dubbo、http协议response异常统一处理 - 支持dubbo、http协议response异常统一处理
- 多语言处理 - 多语言处理处理
# 最佳实践
- controller需要使用@ApiController,否则自定义异常、多语言增强、swagger文档生成等功能将无法生效
- 对于明确的业务异常直接进行抛出,如下方法
```
public User getById(Long id) {
User user = mapper.selectById(id);
if (Objects.isNull(user)) {
throw new BusinessException((AppmsError.USER_NOT_EXIST));
}
return user;
}
```
- controller只做参数转化,对于参数校验、业务逻辑处理放在service处理
# 文档 # 文档
...@@ -55,9 +76,8 @@ ...@@ -55,9 +76,8 @@
return service.getById(id); return service.getById(id);
} }
``` ```
其他部分参照网上示例。
- dubbo-swagger示例 - dubbo-swagger示例
- User - User
...@@ -100,9 +120,8 @@ ...@@ -100,9 +120,8 @@
@ApiOperation( value = "查询用户", notes = "通过id") @ApiOperation( value = "查询用户", notes = "通过id")
public Response<User> getById(@ApiParam("Id") Long id) { public Response<User> getById(@ApiParam("Id") Long id) {
User u = service.getById(id); User u = service.getById(id);
Response response = new Response();
response.setData(u); return ResponseUtil.getSuccessResponse(u);
return response;
} }
....... .......
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment