Commit cba42dae by 李秋伟

Update README.md

parent 2099644d
# 介绍 - # 介绍
protocol-starter提供http、dubbo等协议封装
# 特点
- 支持dubbo、http协议swagger文档
- 支持dubbo、http协议response异常统一处理
- 多语言处理
# 文档
- [dubbo-spring-boot](https://github.com/apache/dubbo-spring-boot-project/blob/master/README_CN.md)
- [swagger常用注解](https://www.jianshu.com/p/f30e0c646c63)
protocol-starter提供http、dubbo等协议封装
# 特点
- 支持dubbo、http协议swagger文档
- 支持dubbo、http协议response异常统一处理
- 多语言处理
# 文档
- [dubbo-spring-boot](https://github.com/apache/dubbo-spring-boot-project/blob/master/README_CN.md)
- [swagger常用注解](https://www.jianshu.com/p/f30e0c646c63)
# 开始
- 添加依赖
- Maven:需要在自己项目的pom.xml增加,以下配置。
**注意:前置条件需要依赖项目中需要设置matrix的parent**
```xml
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>protocol-starter</artifactId>
</dependency>
```
# 示例
- springMvc(略)
- dubbo-swagger示例
- User
```
public class User implements Serializable {
@ApiModelProperty(value = "用户姓名")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
# 开始
}
``` - 添加依赖
- UserDService - Maven:需要在自己项目的pom.xml增加,以下配置。
``` **注意:前置条件需要依赖项目中需要设置matrix的parent**
public interface UserDService {
Response<User> getById(Long id); ```xml
...... <dependency>
} <groupId>com.secoo.mall</groupId>
<artifactId>protocol-starter</artifactId>
</dependency>
``` ```
- UserProvider # 示例
- springMvc
**注意:使用ApiController注解**
``` ```
@Api(value = "用户管理", tags = "用户管理") @Api(value = "用户管理", tags = "用户管理", position = 3)
@Service(version = "1.0.0") @ApiController(value = PathConstant.APPMS + "/user")
public class UserProvider implements UserDService { public class UserController {
@Resource
private UserService service; /*
@Override *根据id查询用户
@ApiOperation( value = "查询用户", notes = "通过id") * @Param id
public Response<User> getById(@ApiParam("Id") Long id) { * @return
User u = service.getById(id); * */
Response response = new Response(); @GetMapping("/getById")
response.setData(u); @ApiOperation(value = "根据id获取用户详细信息", notes = "根据id来获取用户详细信息")
return response; @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long")
public Object getById(Long id) {
return service.getById(id);
} }
.......
}
```
- UserService
``` ```
@Service
public class UserService {
private static final Logger logger = LoggerFactory.getLogger(UserService.class);
public User getById(Long id){
User u = new User(); - dubbo-swagger示例
u.setName("zhangsang");
return u; - User
```
public class User implements Serializable {
@ApiModelProperty(value = "用户姓名")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }
...... ```
}
``` - UserDService
```
public interface UserDService {
Response<User> getById(Long id);
......
- 访问方式 }
```
http://localhost:8080/doc.html
\ No newline at end of file - UserProvider
```
@Api(value = "用户管理", tags = "用户管理")
@Service(version = "1.0.0")
public class UserProvider implements UserDService {
@Resource
private UserService service;
@Override
@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;
}
.......
}
```
- UserService
```
@Service
public class UserService {
private static final Logger logger = LoggerFactory.getLogger(UserService.class);
public User getById(Long id){
User u = new User();
u.setName("zhangsang");
return u;
}
......
}
```
- 访问方式
http://localhost:8080/doc.html
\ No newline at end of file
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