diff --git a/common/common-dubbo/pom.xml b/common/common-dubbo/pom.xml
index e6537a9..16bfced 100644
--- a/common/common-dubbo/pom.xml
+++ b/common/common-dubbo/pom.xml
@@ -12,11 +12,15 @@
common-dubbo
- 3.0.3
+ 3.2.0
UTF-8
+
+ cn.fateverse
+ common-core
+
org.apache.dubbo
dubbo-registry-nacos
@@ -45,6 +49,12 @@
org.apache.dubbo
dubbo-spring-boot-starter
${dubbo.version}
+
+
+ com.alibaba.fastjson2
+ fastjson2
+
+
diff --git a/common/common-log/src/main/java/cn/fateverse/common/log/LogAutoConfiguration.java b/common/common-log/src/main/java/cn/fateverse/common/log/LogAutoConfiguration.java
index 005a4e8..26b0e44 100644
--- a/common/common-log/src/main/java/cn/fateverse/common/log/LogAutoConfiguration.java
+++ b/common/common-log/src/main/java/cn/fateverse/common/log/LogAutoConfiguration.java
@@ -6,6 +6,7 @@ import cn.fateverse.common.log.service.OperationService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
/**
@@ -17,13 +18,13 @@ import org.springframework.context.annotation.Bean;
public class LogAutoConfiguration {
@Bean
- public LogAspect logAspect(){
+ public LogAspect logAspect() {
return new LogAspect();
}
@Bean
- public OperationService operationService(OperationProperties properties) {
- return new OperationService(properties);
+ public OperationService operationService(OperationProperties properties, Environment environment) {
+ return new OperationService(properties, environment);
}
}
diff --git a/common/common-log/src/main/java/cn/fateverse/common/log/service/OperationService.java b/common/common-log/src/main/java/cn/fateverse/common/log/service/OperationService.java
index 3348e02..09cc235 100644
--- a/common/common-log/src/main/java/cn/fateverse/common/log/service/OperationService.java
+++ b/common/common-log/src/main/java/cn/fateverse/common/log/service/OperationService.java
@@ -11,10 +11,12 @@ import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.ObjectUtils;
import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -35,14 +37,23 @@ public class OperationService {
@DubboReference
private DubboLogService logService;
+
+ private final String applicationName;
+
private final OperationProperties properties;
private final List operationLogListCache;
- public OperationService(OperationProperties properties) {
+ public OperationService(OperationProperties properties, Environment environment) {
this.properties = properties;
this.operationLogListCache = new ArrayList<>(properties.getCacheSize());
+ String applicationName = environment.getProperty("spring.application.name");
+ if (ObjectUtils.isEmpty(applicationName)) {
+ log.error("applicationName can not be null");
+ throw new RuntimeException("applicationName can not be null");
+ }
+ this.applicationName = applicationName;
}
@@ -62,6 +73,7 @@ public class OperationService {
@Async
public void asyncExecute(OperationLog operationLog, Object jsonResult, Throwable e, Long time) {
operationLog.setState(BusinessState.SUCCESS.ordinal());
+ operationLog.setApplicationName(applicationName);
// 返回参数
if (jsonResult instanceof Result) {
Result