add lombok
This commit is contained in:
@@ -38,7 +38,7 @@ public class AOPLogInterceptor {
|
||||
}
|
||||
|
||||
/** 注入注解 */
|
||||
@Pointcut("@annotation(annotation.com.imyeyu.spring.AOPLog)")
|
||||
@Pointcut("@annotation(com.imyeyu.spring.annotation.AOPLog)")
|
||||
public void logPointCut() {
|
||||
}
|
||||
|
||||
@@ -63,41 +63,45 @@ public class AOPLogInterceptor {
|
||||
@AfterReturning(returning = "response", pointcut = "logPointCut()")
|
||||
public void doAfterReturning(Object response) throws Throwable {
|
||||
String msg = "ID: {} Response <- Return.";
|
||||
if (response instanceof IDEntity<?> entity) {
|
||||
// 返回实体
|
||||
msg += entity.getClass().getSimpleName() + "." + entity.getId();
|
||||
} else if (response instanceof PageResult<?> pageResult) {
|
||||
// 返回数组
|
||||
if (pageResult.getList().isEmpty()) {
|
||||
msg += "PageResult<?> Empty";
|
||||
} else {
|
||||
if (pageResult.getList().get(0) == null) {
|
||||
msg += "PageResult<?>." + pageResult.getList().size();
|
||||
switch (response) {
|
||||
case IDEntity<?> entity ->
|
||||
// 返回实体
|
||||
msg += entity.getClass().getSimpleName() + "." + entity.getId();
|
||||
case PageResult<?> pageResult -> {
|
||||
// 返回数组
|
||||
if (pageResult.getList().isEmpty()) {
|
||||
msg += "PageResult<?> Empty";
|
||||
} else {
|
||||
msg += "PageResult<" + pageResult.getList().get(0).getClass().getSimpleName() + ">[" + pageResult.getList().size() + "]";
|
||||
if (pageResult.getList().getFirst() == null) {
|
||||
msg += "PageResult<?>." + pageResult.getList().size();
|
||||
} else {
|
||||
msg += "PageResult<%s>[%s]".formatted(pageResult.getList().getFirst().getClass().getSimpleName(), pageResult.getList().size());
|
||||
}
|
||||
}
|
||||
// 返回数据页
|
||||
}
|
||||
// 返回数据页
|
||||
} else if (response instanceof String string) {
|
||||
// 返回字符串
|
||||
if (string.length() < 64) {
|
||||
msg += string;
|
||||
} else {
|
||||
msg += string.substring(0, 64) + "..";
|
||||
case String string -> {
|
||||
// 返回字符串
|
||||
if (string.length() < 64) {
|
||||
msg += string;
|
||||
} else {
|
||||
msg += string.substring(0, 64) + "..";
|
||||
}
|
||||
msg = msg.replaceAll("[\\r\\n]+", "");
|
||||
}
|
||||
msg = msg.replaceAll("[\\r\\n]+", "");
|
||||
} else if (response instanceof Boolean bool) {
|
||||
// 返回布尔值
|
||||
msg += bool;
|
||||
} else if (response instanceof Number number) {
|
||||
// 返回数字
|
||||
msg += response.getClass().getSimpleName() + ".[" + number.doubleValue() + "]";
|
||||
} else {
|
||||
// 其他对象
|
||||
if (TimiJava.isNotEmpty(response)) {
|
||||
msg += response.getClass().getSimpleName();
|
||||
} else {
|
||||
msg += "NULL";
|
||||
case Boolean bool ->
|
||||
// 返回布尔值
|
||||
msg += bool;
|
||||
case Number number ->
|
||||
// 返回数字
|
||||
msg += response.getClass().getSimpleName() + ".[" + number.doubleValue() + "]";
|
||||
case null, default -> {
|
||||
// 其他对象
|
||||
if (TimiJava.isNotEmpty(response)) {
|
||||
msg += response.getClass().getSimpleName();
|
||||
} else {
|
||||
msg += "NULL";
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info(msg, TimiSpring.getSessionAttr(REQUEST_ID));
|
||||
|
||||
Reference in New Issue
Block a user