# Simplify-rest
**Repository Path**: fanjr/simplify-rest
## Basic Information
- **Project Name**: Simplify-rest
- **Description**: 基于SpringMvc进行二次开发的一套注解工具包,自动暴露注解类的公有方法,旨在减少控制层的部分copy操作
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 6
- **Forks**: 0
- **Created**: 2019-11-21
- **Last Updated**: 2023-06-10
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Simplify-rest
#### 介绍
基于SpringMvc进行二次开发的一套注解工具包,自动暴露注解类的共有方法,旨在减少控制层的部分copy操作,能偷点懒是一点 :-)
目前2.0.0已经发布到中央仓库
##### 主要特点
1. 使用方便,一个注解解决大量注册Mapping时需要重复填写的path
2. 与原生SpringMvc使用方式完全兼容
3. 最小仅依赖于SpringMvc相关包和SLF4J
4. 支持springboot以及非springboot的模式
##### 使用效果如下
##### BEFORE
```
@RestController
@RequestMapping("/test")
public class HelloController {
@RequestMapping("/hello1")
public String hello1(String name) {
return "hello " + name + "!";
}
@RequestMapping("/hello2")
public String hello2(TestPojo pojo) {
return pojo.toString();
}
@RequestMapping("/hello3/{type}")
public String hello3(@PathVariable(value = "type") String type){
return type;
}
public String skip(){
return "skip";
}
}
```
##### AFTER
```
@Rest("test")
public class HelloController {
//自动暴露到/test/hello1
public String hello1(String name) {
return "hello " + name + "!";
}
//自动暴露到/test/hello2
public String hello2(TestPojo pojo) {
return pojo.toString();
}
//原生SpringMvc模式
@RequestMapping("/hello3/{type}")
public String hello3(@PathVariable(value = "type") String type){
return type;
}
//跳过这个公共方法的注册
@SkipMapping
public String skip(){
return skip1();
}
//私有方法不注册
privae String skip1(){
return "skip";
}
}
//将@RestInterface标注在接口上,实现这个接口并注册成springBean时,会自动暴露这个接口下面的方法
//考虑到一个接口可能有数个实现,将以BeanName作为根路径
@RestInterface
public interface TestInter {
String hello();
String hello1(String name);
String hello3(TestPojo body);
@SkipMapping //跳过这个方法的注册
public String skipService2();
}
```
#### 使用说明
##### 1. 使用springboot
引入模块,即可使用
```
org.fanjr.simplify
simplify-rest-starter
2.0.0
```
##### 2. 仅使用spring
引入模块
```
org.fanjr.simplify
simplify-rest-core
2.0.0
```
另外配置springbean如下
```
```