Skip to content

Commit 46fcb35

Browse files
authored
Merge pull request #12 from Frodez/0.3-alpha
0.3 alpha
2 parents c032739 + 17344c1 commit 46fcb35

File tree

88 files changed

+1477
-894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1477
-894
lines changed

pom.xml

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>2.1.3.RELEASE</version>
18+
<version>2.1.4.RELEASE</version>
1919
<relativePath /> <!-- lookup parent from repository -->
2020
</parent>
2121

@@ -57,6 +57,10 @@
5757
<groupId>org.springframework.boot</groupId>
5858
<artifactId>spring-boot-starter-tomcat</artifactId>
5959
</exclusion>
60+
<exclusion>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-starter-json</artifactId>
63+
</exclusion>
6064
</exclusions>
6165
</dependency>
6266
<dependency>
@@ -66,7 +70,7 @@
6670
<dependency>
6771
<groupId>org.mybatis.spring.boot</groupId>
6872
<artifactId>mybatis-spring-boot-starter</artifactId>
69-
<version>2.0.0</version>
73+
<version>2.0.1</version>
7074
</dependency>
7175
<dependency>
7276
<groupId>org.projectlombok</groupId>
@@ -107,23 +111,19 @@
107111
</dependency>
108112

109113
<!-- tk-mybatis -->
110-
<dependency>
111-
<groupId>tk.mybatis</groupId>
112-
<artifactId>mapper</artifactId>
113-
<version>4.1.5</version>
114-
</dependency>
115114
<dependency>
116115
<groupId>tk.mybatis</groupId>
117116
<artifactId>mapper-spring-boot-starter</artifactId>
118117
<version>2.1.5</version>
118+
<exclusions>
119+
<exclusion>
120+
<groupId>tk.mybatis</groupId>
121+
<artifactId>mapper-weekend</artifactId>
122+
</exclusion>
123+
</exclusions>
119124
</dependency>
120125

121126
<!-- pagehelper -->
122-
<dependency>
123-
<groupId>com.github.pagehelper</groupId>
124-
<artifactId>pagehelper</artifactId>
125-
<version>5.1.8</version>
126-
</dependency>
127127
<dependency>
128128
<groupId>com.github.pagehelper</groupId>
129129
<artifactId>pagehelper-spring-boot-starter</artifactId>
@@ -160,6 +160,33 @@
160160
<groupId>com.google.guava</groupId>
161161
<artifactId>guava</artifactId>
162162
<version>27.1-jre</version>
163+
<exclusions>
164+
<!-- 这几个依赖用于编译器增强,需要者可以引入,用于编写编译器相关插件,增强代码检查等方面功能 -->
165+
<exclusion>
166+
<groupId>com.google.guava</groupId>
167+
<artifactId>listenablefuture</artifactId>
168+
</exclusion>
169+
<exclusion>
170+
<groupId>org.codehaus.mojo</groupId>
171+
<artifactId>animal-sniffer-annotations</artifactId>
172+
</exclusion>
173+
<exclusion>
174+
<groupId>com.google.j2objc</groupId>
175+
<artifactId>j2objc-annotations</artifactId>
176+
</exclusion>
177+
<exclusion>
178+
<groupId>com.google.code.findbugs</groupId>
179+
<artifactId>jsr305</artifactId>
180+
</exclusion>
181+
<exclusion>
182+
<groupId>org.checkerframework</groupId>
183+
<artifactId>checker-qual</artifactId>
184+
</exclusion>
185+
<exclusion>
186+
<groupId>com.google.errorprone</groupId>
187+
<artifactId>error_prone_annotations</artifactId>
188+
</exclusion>
189+
</exclusions>
163190
</dependency>
164191

165192
<!-- log4j2 -->
@@ -193,19 +220,25 @@
193220
<dependency>
194221
<groupId>org.apache.poi</groupId>
195222
<artifactId>poi</artifactId>
196-
<version>4.0.1</version>
223+
<version>4.1.0</version>
197224
</dependency>
198225
<!-- poi-ooxml -->
199226
<dependency>
200227
<groupId>org.apache.poi</groupId>
201228
<artifactId>poi-ooxml</artifactId>
202-
<version>4.0.1</version>
229+
<version>4.1.0</version>
230+
<exclusions>
231+
<exclusion>
232+
<groupId>org.apache.poi</groupId>
233+
<artifactId>poi-ooxml-schemas</artifactId>
234+
</exclusion>
235+
</exclusions>
203236
</dependency>
204237
<!-- poi-scratchpad -->
205238
<dependency>
206239
<groupId>org.apache.poi</groupId>
207240
<artifactId>poi-scratchpad</artifactId>
208-
<version>4.0.1</version>
241+
<version>4.1.0</version>
209242
</dependency>
210243

211244
<!-- org.eclipse.jdt.core -->

src/main/generator/jdt/JDTUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private static void attachAnnotation(List<Object> list, org.eclipse.jdt.core.dom
183183
if (iterator.next() instanceof Modifier) {
184184
break;
185185
}
186-
index++;
186+
++index;
187187
}
188188
list.add(index, annotation);
189189
}

src/main/generator/mybatis/CustomCommentGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void addModelClassComment(TopLevelClass klass, IntrospectedTable table) {
3232
klass.addImportedType("io.swagger.annotations.ApiModelProperty");
3333
for (IntrospectedColumn iter : table.getAllColumns()) {
3434
if (iter.isNullable()) {
35-
klass.addImportedType("javax.annotation.Nullable");
35+
klass.addImportedType("org.springframework.lang.Nullable");
3636
break;
3737
}
3838
}

src/main/generator/mybatis/CustomXmlFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static String getFormattedContent(XmlElement element, int indentLevel) {
7070
}
7171

7272
public static void xmlIndent(StringBuilder sb, int indentLevel) {
73-
for (int i = 0; i < indentLevel; i++) {
73+
for (int i = 0; i < indentLevel; ++i) {
7474
sb.append(" ");
7575
}
7676
}

src/main/java/frodez/config/aop/log/LogAOP.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package frodez.config.aop.log;
22

3+
import frodez.config.aop.log.annotation.DurationLog;
34
import frodez.util.aop.AspectUtil;
45
import frodez.util.json.JSONUtil;
56
import java.lang.reflect.Parameter;
@@ -37,7 +38,7 @@ public void printParam(JoinPoint point) {
3738
Parameter[] parameters = AspectUtil.params(point);
3839
Object[] args = point.getArgs();
3940
Map<String, Object> paramMap = new HashMap<>();
40-
for (int i = 0; i < parameters.length; i++) {
41+
for (int i = 0; i < parameters.length; ++i) {
4142
paramMap.put(parameters[i].getName(), args[i]);
4243
}
4344
log.info("{} 请求参数:{}", AspectUtil.fullMethodName(point), JSONUtil.string(paramMap));
@@ -62,12 +63,12 @@ public void printResult(JoinPoint point, Object result) {
6263
* @date 2018-12-21
6364
*/
6465
@Around("@annotation(frodez.config.aop.log.annotation.MethodLog)")
65-
public Object process(ProceedingJoinPoint point) throws Throwable {
66+
public Object log(ProceedingJoinPoint point) throws Throwable {
6667
Parameter[] parameters = AspectUtil.params(point);
6768
String fullName = AspectUtil.fullMethodName(point);
6869
Object[] args = point.getArgs();
6970
Map<String, Object> paramMap = new HashMap<>();
70-
for (int i = 0; i < parameters.length; i++) {
71+
for (int i = 0; i < parameters.length; ++i) {
7172
paramMap.put(parameters[i].getName(), args[i]);
7273
}
7374
log.info("{} 请求参数:{}", fullName, JSONUtil.string(paramMap));
@@ -76,4 +77,23 @@ public Object process(ProceedingJoinPoint point) throws Throwable {
7677
return result;
7778
}
7879

80+
/**
81+
* 打印方法耗时到日志
82+
* @param JoinPoint AOP切点
83+
* @author Frodez
84+
* @throws Throwable
85+
* @date 2018-12-21
86+
*/
87+
@Around("@annotation(frodez.config.aop.log.annotation.DurationLog)")
88+
public Object countDuration(ProceedingJoinPoint point) throws Throwable {
89+
long count = System.currentTimeMillis();
90+
DurationLog durationLog = AspectUtil.annotation(point, DurationLog.class);
91+
Object result = point.proceed();
92+
count = count - System.currentTimeMillis();
93+
if (count > durationLog.threshold()) {
94+
log.warn("{}方法耗时{}毫秒,触发超时警告!", AspectUtil.fullMethodName(point), durationLog.threshold());
95+
}
96+
return result;
97+
}
98+
7999
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package frodez.config.aop.log.annotation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* 方法耗时监控注解
11+
* @author Frodez
12+
* @date 2019-01-12
13+
*/
14+
@Documented
15+
@Target({ ElementType.METHOD })
16+
@Retention(RetentionPolicy.RUNTIME)
17+
public @interface DurationLog {
18+
19+
/**
20+
* 警告触发阈值,默认3000毫秒
21+
* @author Frodez
22+
* @date 2019-04-13
23+
*/
24+
long threshold() default 3000;
25+
26+
}

src/main/java/frodez/config/aop/request/TimeoutAOP.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class TimeoutAOP {
4949
public Object process(ProceedingJoinPoint point) throws Throwable {
5050
HttpServletRequest request = MVCUtil.request();
5151
TimeoutLock timeoutLock = AspectUtil.annotation(point, TimeoutLock.class);
52+
if (timeoutLock.value() < 0) {
53+
throw new IllegalArgumentException("the timeout can't be negative!");
54+
}
5255
String key = KeyGenerator.servletKey(AspectUtil.fullMethodName(point), request);
5356
if (checker.check(key)) {
5457
log.info("重复请求:IP地址{}", ServletUtil.getAddr(request));

src/main/java/frodez/config/aop/request/annotation/Limit.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
@Retention(RetentionPolicy.RUNTIME)
1717
public @interface Limit {
1818

19-
// 每秒每token限制请求数,默认值100.0
19+
/**
20+
* 每秒每token限制请求数,默认值100.0
21+
* @author Frodez
22+
* @date 2019-04-13
23+
*/
2024
double value() default 100.0;
2125

22-
// 超时时间,默认值1000毫秒
26+
/**
27+
* 超时时间,默认值3000毫秒
28+
* @author Frodez
29+
* @date 2019-04-13
30+
*/
2331
long timeout() default 3000;
2432

2533
}

src/main/java/frodez/config/aop/request/annotation/TimeoutLock.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
@Retention(RetentionPolicy.RUNTIME)
1717
public @interface TimeoutLock {
1818

19-
// 过期时间,大于等于0,单位毫秒,默认值500
19+
/**
20+
* 过期时间,大于等于0,单位毫秒,默认值500 <strong>如果设置了小于等于0的值,会在启动时抛出异常。</strong>
21+
* @author Frodez
22+
* @date 2019-04-13
23+
*/
2024
long value() default 500;
2125

2226
}

src/main/java/frodez/config/aop/request/checker/impl/KeyGenerator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package frodez.config.aop.request.checker.impl;
22

3-
import frodez.config.security.util.TokenManager;
3+
import frodez.config.security.util.TokenUtil;
4+
import frodez.util.common.StrUtil;
45
import frodez.util.constant.setting.DefStr;
56
import frodez.util.http.ServletUtil;
67
import frodez.util.http.URLMatcher;
@@ -11,18 +12,18 @@
1112
public class KeyGenerator {
1213

1314
public static String servletKey(String sault, HttpServletRequest request) {
14-
String key = sault.concat(DefStr.SEPERATOR).concat(request.getRequestURI());
15+
String key = StrUtil.concat(sault, DefStr.SEPERATOR, request.getRequestURI());
1516
if (URLMatcher.needVerify(request.getRequestURI())) {
1617
// 非登录接口使用token判断,同一token不能重复请求
17-
String fullToken = TokenManager.getFullToken(request);
18+
String fullToken = TokenUtil.getFullToken(request);
1819
if (fullToken == null) {
1920
return key;
2021
} else {
21-
return key.concat(DefStr.SEPERATOR).concat(fullToken);
22+
return StrUtil.concat(key, DefStr.SEPERATOR, fullToken);
2223
}
2324
} else {
2425
// 登录接口使用IP判断,同一IP不能重复请求
25-
return key.concat(DefStr.SEPERATOR).concat(ServletUtil.getAddr(request));
26+
return StrUtil.concat(key, DefStr.SEPERATOR, ServletUtil.getAddr(request));
2627
}
2728
}
2829

0 commit comments

Comments
 (0)