Skip to content

Commit 5f5fc50

Browse files
note
1 parent 25da0b7 commit 5f5fc50

File tree

8 files changed

+16
-5
lines changed

8 files changed

+16
-5
lines changed

src/main/java/com/aspect/HttpAspect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
/**
1414
* Created by zhuzhengping on 2017/3/19.
15-
* aop切面,对每一个请求做记录
15+
* aop切面,对每一个在controller请求之前做记录
1616
*/
1717
@Aspect
1818
@Component
1919
public class HttpAspect {
2020

2121
private final static Logger LOGGER = LoggerFactory.getLogger(HttpAspect.class);
2222

23-
@Pointcut("execution(public * com.controller.*.*(..))")
23+
@Pointcut("execution(public * com.controller.*.*(..))")//切面所切的位置
2424
public void log(){
2525
}
2626

27-
@Before("log()")
27+
@Before("log()")//请求之前
2828
public void before(JoinPoint joinPoint){
2929
// System.out.println("this is the aspect before every requset!!!!");
3030
LOGGER.info("this is the aspect before every requset!!!!");
@@ -44,12 +44,12 @@ public void before(JoinPoint joinPoint){
4444
LOGGER.info("args={}",joinPoint.getArgs());
4545
}
4646

47-
@After("log()")
47+
@After("log()")//请求之后
4848
public void after(){
4949
LOGGER.info("this is the aspect after every response!!!");
5050
}
5151

52-
@AfterReturning(pointcut = "log()",returning = "object")
52+
@AfterReturning(pointcut = "log()",returning = "object")//打印输出结果
5353
public void doAfterReturing(Object object){
5454
LOGGER.info("response={}",object);
5555
}

src/main/java/com/common/BootException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* Created by zhuzhengping on 2017/3/21.
5+
* 自定义的异常类
6+
* 添加一场代码code
57
*/
68
public class BootException extends RuntimeException {
79

src/main/java/com/common/ExceptionEnum.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* Created by zhuzhengping on 2017/3/21.
5+
* 异常枚举
6+
* 便于维护
57
*/
68
public enum ExceptionEnum {
79
UNKONW_ERROR(-1,"未知错误"),

src/main/java/com/common/ExceptionHandle.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* Created by zhuzhengping on 2017/3/21.
12+
* 异常记录
13+
* 便于在log中寻找
1214
*/
1315

1416
@ControllerAdvice

src/main/java/com/common/ResultUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/**
66
* Created by zhuzhengping on 2017/3/21.
77
* resultutil to form the result
8+
* 结果封装,统一输出结果以及异常
89
*/
910
public class ResultUtil {
1011

src/main/java/com/compont/Result.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* Created by zhuzhengping on 2017/3/21.
5+
* 结果实体类,使用泛型
56
*/
67
public class Result<T> {
78

src/main/java/com/dao/AuthorDao_jdbc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.dao;
22

33
import com.compont.Author;
4+
import org.springframework.stereotype.Component;
45

56
import java.util.List;
67

78
/**
89
* Created by zhuzhengping on 2017/3/7.
910
* jdbc链接数据库dao层
1011
*/
12+
@Component
1113
public interface AuthorDao_jdbc {
1214

1315
int add(Author author);

src/test/java/com/controller/AuthorControllerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/**
1414
* Created by zhuzhengping on 2017/3/21.
15+
* api单元测试,可测试具体url地址
1516
*/
1617

1718
@RunWith(SpringRunner.class)

0 commit comments

Comments
 (0)