Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
1e73d049
Commit
1e73d049
authored
Aug 14, 2019
by
李秋伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README.md
parent
bf9a96a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
README.md
protocol-starter/README.md
+25
-6
No files found.
protocol-starter/README.md
View file @
1e73d049
...
...
@@ -5,7 +5,28 @@
-
支持dubbo、http协议swagger文档
-
支持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 @@
return service.getById(id);
}
```
其他部分参照网上示例。
-
dubbo-swagger示例
-
User
...
...
@@ -100,9 +120,8 @@
@ApiOperation( value = "查询用户", notes = "通过id")
public Response<User> getById(@ApiParam("Id") Long id) {
User u = service.getById(id);
Response response = new Response();
response.setData(u);
return response;
return ResponseUtil.getSuccessResponse(u);
}
.......
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment