diff --git a/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateAddPO.java b/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateAddPO.java
deleted file mode 100644
index 9385c9677..000000000
--- a/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateAddPO.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.iocoder.mall.system.application.po.sms;
-
-import cn.iocoder.common.framework.validator.InEnum;
-import cn.iocoder.mall.system.api.constant.SmsPlatformEnum;
-import cn.iocoder.mall.system.api.constant.SmsTypeEnum;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import java.io.Serializable;
-
-/**
- * 短信模板 add
- *
- * @author Sin
- * @time 2019/5/26 12:37 PM
- */
-@ApiModel("短信模板-添加")
-@Data
-@Accessors(chain = true)
-public class SmsTemplateAddPO implements Serializable {
-
- @ApiModelProperty("短信签名id")
- @NotNull(message = "短信短信签名id不能为空!")
- private Integer smsSignId;
-
- @ApiModelProperty("短信模板code")
- @NotNull
- @Size(min = 3, max = 50, message = "短信code在 3-50 之间")
- private String templateCode;
-
- @ApiModelProperty("短信模板")
- @NotNull
- @Size(min = 3, max = 255, message = "短信在 3-255 之间")
- private String template;
-
- @ApiModelProperty("短信模板-平台")
- @NotNull
- @InEnum(value = SmsPlatformEnum.class)
- private Integer platform;
-
- @ApiModelProperty("短信模板-平台")
- @NotNull
- @InEnum(value = SmsTypeEnum.class)
- private Integer smsType;
-}
diff --git a/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateUpdatePO.java b/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateUpdatePO.java
deleted file mode 100644
index f477804c3..000000000
--- a/moved/system/system-start/src/main/java/cn/iocoder/mall/system/application/po/sms/SmsTemplateUpdatePO.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.iocoder.mall.system.application.po.sms;
-
-import cn.iocoder.common.framework.validator.InEnum;
-import cn.iocoder.mall.system.api.constant.SmsPlatformEnum;
-import cn.iocoder.mall.system.api.constant.SmsTypeEnum;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import java.io.Serializable;
-
-/**
- * 短信模板 add
- *
- * @author Sin
- * @time 2019/5/26 12:37 PM
- */
-@ApiModel("短信模板-添加")
-@Data
-@Accessors(chain = true)
-public class SmsTemplateUpdatePO implements Serializable {
-
- @ApiModelProperty("短信模板id")
- @NotNull(message = "短信模板不能为空!")
- private Integer id;
-
- @ApiModelProperty("短信签名id")
- @NotNull(message = "短信短信签名id不能为空!")
- private Integer smsSignId;
-
- @ApiModelProperty("短信模板code")
- @NotNull
- @Size(min = 3, max = 50, message = "短信code在 3-50 之间")
- private String templateCode;
-
- @ApiModelProperty("短信模板")
- @NotNull
- @Size(min = 3, max = 255, message = "短信在 3-255 之间")
- private String template;
-
- @ApiModelProperty("短信模板-平台")
- @NotNull
- @InEnum(value = SmsPlatformEnum.class)
- private Integer platform;
-
- @ApiModelProperty("短信模板-平台")
- @NotNull
- @InEnum(value = SmsTypeEnum.class)
- private Integer smsType;
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
index 5e3054ff0..a04a2f1b0 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
@@ -53,13 +53,26 @@
provided
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-rpc
+ true
+
+
+
+
+ cn.iocoder.cloud
+ yudao-module-infra-api
+ ${revision}
+
+
io.github.resilience4j
resilience4j-ratelimiter
provided
-
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
index 7dc78c445..e41f5b036 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
@@ -2,9 +2,14 @@ package cn.iocoder.yudao.framework.apilog.config;
import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl;
import cn.iocoder.yudao.framework.web.config.WebProperties;
import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
+import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
+import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -17,6 +22,16 @@ import javax.servlet.Filter;
@AutoConfigureAfter(YudaoWebAutoConfiguration.class)
public class YudaoApiLogAutoConfiguration {
+ @Bean
+ public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) {
+ return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi);
+ }
+
+ @Bean
+ public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) {
+ return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi);
+ }
+
/**
* 创建 ApiAccessLogFilter Bean,记录 API 请求日志
*/
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogRpcAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogRpcAutoConfiguration.java
new file mode 100644
index 000000000..a9a53173c
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogRpcAutoConfiguration.java
@@ -0,0 +1,17 @@
+package cn.iocoder.yudao.framework.apilog.config;
+
+import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
+import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * API 日志使用到 Feign 的配置项
+ *
+ * @author 芋道源码
+ */
+@Configuration(proxyBeanMethods = false)
+@EnableFeignClients(clients = {ApiAccessLogApi.class, // 主要是引入相关的 API 服务
+ ApiErrorLogApi.class})
+public class YudaoApiLogRpcAutoConfiguration {
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java
index a0bdf64c8..6417189b0 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java
@@ -3,8 +3,8 @@ package cn.iocoder.yudao.framework.apilog.core.filter;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.extra.servlet.ServletUtil;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
@@ -66,16 +66,16 @@ public class ApiAccessLogFilter extends ApiRequestFilter {
private void createApiAccessLog(HttpServletRequest request, Date beginTime,
Map queryString, String requestBody, Exception ex) {
- ApiAccessLogCreateReqDTO accessLog = new ApiAccessLogCreateReqDTO();
+ ApiAccessLog accessLog = new ApiAccessLog();
try {
this.buildApiAccessLogDTO(accessLog, request, beginTime, queryString, requestBody, ex);
- apiAccessLogFrameworkService.createApiAccessLogAsync(accessLog);
+ apiAccessLogFrameworkService.createApiAccessLog(accessLog);
} catch (Throwable th) {
log.error("[createApiAccessLog][url({}) log({}) 发生异常]", request.getRequestURI(), toJsonString(accessLog), th);
}
}
- private void buildApiAccessLogDTO(ApiAccessLogCreateReqDTO accessLog, HttpServletRequest request, Date beginTime,
+ private void buildApiAccessLogDTO(ApiAccessLog accessLog, HttpServletRequest request, Date beginTime,
Map queryString, String requestBody, Exception ex) {
// 处理用户信息
accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java
similarity index 92%
rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java
rename to yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java
index a32f7b346..a92b06c26 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.framework.apilog.core.service.dto;
+package cn.iocoder.yudao.framework.apilog.core.service;
import lombok.Data;
@@ -6,12 +6,12 @@ import javax.validation.constraints.NotNull;
import java.util.Date;
/**
- * API 访问日志创建 DTO
+ * API 访问日志
*
* @author 芋道源码
*/
@Data
-public class ApiAccessLogCreateReqDTO {
+public class ApiAccessLog {
/**
* 链路追踪编号
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java
index 71df0f6fb..9bfc3a573 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java
@@ -1,9 +1,5 @@
package cn.iocoder.yudao.framework.apilog.core.service;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
-
-import javax.validation.Valid;
-
/**
* API 访问日志 Framework Service 接口
*
@@ -14,8 +10,8 @@ public interface ApiAccessLogFrameworkService {
/**
* 创建 API 访问日志
*
- * @param createDTO 创建信息
+ * @param apiAccessLog API 访问日志
*/
- void createApiAccessLogAsync(@Valid ApiAccessLogCreateReqDTO createDTO);
+ void createApiAccessLog(ApiAccessLog apiAccessLog);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java
new file mode 100644
index 000000000..8ea5ebbc1
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.framework.apilog.core.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.scheduling.annotation.Async;
+
+/**
+ * API 访问日志 Framework Service 实现类
+ *
+ * 基于 {@link ApiAccessLogApi} 远程服务,记录访问日志
+ *
+ * @author 芋道源码
+ */
+@RequiredArgsConstructor
+public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService {
+
+ private final ApiAccessLogApi apiAccessLogApi;
+
+ @Override
+ @Async
+ public void createApiAccessLog(ApiAccessLog apiAccessLog) {
+ ApiAccessLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiAccessLog, ApiAccessLogCreateReqDTO.class);
+ CommonResult result = apiAccessLogApi.createApiAccessLog(reqDTO);
+ result.checkError();
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java
similarity index 92%
rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java
rename to yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java
index 70baebc5c..3f5d539cb 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java
@@ -1,19 +1,17 @@
-package cn.iocoder.yudao.framework.apilog.core.service.dto;
+package cn.iocoder.yudao.framework.apilog.core.service;
import lombok.Data;
-import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
- * API 错误日志创建 DTO
+ * API 错误日志
*
* @author 芋道源码
*/
@Data
-@Accessors(chain = true)
-public class ApiErrorLogCreateReqDTO {
+public class ApiErrorLog {
/**
* 链路编号
@@ -105,4 +103,5 @@ public class ApiErrorLogCreateReqDTO {
@NotNull(message = "异常导致的消息不能为空")
private String exceptionMessage;
+
}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java
index 9229745d7..403c574bc 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java
@@ -1,9 +1,5 @@
package cn.iocoder.yudao.framework.apilog.core.service;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
-
-import javax.validation.Valid;
-
/**
* API 错误日志 Framework Service 接口
*
@@ -14,8 +10,8 @@ public interface ApiErrorLogFrameworkService {
/**
* 创建 API 错误日志
*
- * @param createDTO 创建信息
+ * @param apiErrorLog API 错误日志
*/
- void createApiErrorLogAsync(@Valid ApiErrorLogCreateReqDTO createDTO);
+ void createApiErrorLog(ApiErrorLog apiErrorLog);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
new file mode 100644
index 000000000..4db4f59ea
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.framework.apilog.core.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.scheduling.annotation.Async;
+
+/**
+ * API 错误日志 Framework Service 实现类
+ *
+ * 基于 {@link ApiErrorLogApi} 远程服务,记录错误日志
+ *
+ * @author 芋道源码
+ */
+@RequiredArgsConstructor
+public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService {
+
+ private final ApiErrorLogApi apiErrorLogApi;
+
+ @Override
+ @Async
+ public void createApiErrorLog(ApiErrorLog apiErrorLog) {
+ ApiErrorLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiErrorLog, ApiErrorLogCreateReqDTO.class);
+ CommonResult result = apiErrorLogApi.createApiErrorLog(reqDTO);
+ result.checkError();
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
index bbad8276d..fdf77de96 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
@@ -3,15 +3,14 @@ package cn.iocoder.yudao.framework.web.core.handler;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.extra.servlet.ServletUtil;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
-import io.github.resilience4j.ratelimiter.RequestNotPermitted;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -230,18 +229,18 @@ public class GlobalExceptionHandler {
private void createExceptionLog(HttpServletRequest req, Throwable e) {
// 插入错误日志
- ApiErrorLogCreateReqDTO errorLog = new ApiErrorLogCreateReqDTO();
+ ApiErrorLog errorLog = new ApiErrorLog();
try {
// 初始化 errorLog
initExceptionLog(errorLog, req, e);
// 执行插入 errorLog
- apiErrorLogFrameworkService.createApiErrorLogAsync(errorLog);
+ apiErrorLogFrameworkService.createApiErrorLog(errorLog);
} catch (Throwable th) {
log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th);
}
}
- private void initExceptionLog(ApiErrorLogCreateReqDTO errorLog, HttpServletRequest request, Throwable e) {
+ private void initExceptionLog(ApiErrorLog errorLog, HttpServletRequest request, Throwable e) {
// 处理用户信息
errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request));
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring.factories
index 3b0e1d772..8f5372013 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring.factories
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring.factories
@@ -1,4 +1,5 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+ cn.iocoder.yudao.framework.apilog.config.YudaoApiLogRpcAutoConfiguration,\
cn.iocoder.yudao.framework.apilog.config.YudaoApiLogAutoConfiguration,\
cn.iocoder.yudao.framework.jackson.config.YudaoJacksonAutoConfiguration,\
cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration,\
diff --git a/yudao-module-infra/yudao-module-infra-api/pom.xml b/yudao-module-infra/yudao-module-infra-api/pom.xml
index a3833a416..003b7d7f0 100644
--- a/yudao-module-infra/yudao-module-infra-api/pom.xml
+++ b/yudao-module-infra/yudao-module-infra-api/pom.xml
@@ -21,6 +21,27 @@
cn.iocoder.cloud
yudao-common
+
+
+
+ io.swagger
+ swagger-annotations
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+ true
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+ true
+
diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java
new file mode 100644
index 000000000..deecb78df
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.infra.api.logger;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.module.infra.enums.ApiConstants;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+
+@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
+@Api(tags = "RPC 服务 - API 访问日志")
+public interface ApiAccessLogApi {
+
+ String PREFIX = ApiConstants.PREFIX + "/api-access-log";
+
+ @PostMapping(PREFIX + "/create")
+ @ApiOperation("创建 API 访问日志")
+ CommonResult createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java
new file mode 100644
index 000000000..3803f452b
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.infra.api.logger;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
+import cn.iocoder.yudao.module.infra.enums.ApiConstants;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+
+@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
+@Api(tags = "RPC 服务 - API 异常日志")
+public interface ApiErrorLogApi {
+
+ String PREFIX = ApiConstants.PREFIX + "/api-error-log";
+
+ @PostMapping(PREFIX + "/create")
+ @ApiOperation("创建 API 异常日志")
+ CommonResult createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java
new file mode 100644
index 000000000..ea310e477
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java
@@ -0,0 +1,56 @@
+package cn.iocoder.yudao.module.infra.api.logger.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+@ApiModel("API 访问日志创建 Request DTO")
+@Data
+public class ApiAccessLogCreateReqDTO {
+
+ @ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
+ private String traceId;
+
+ @ApiModelProperty(value = "用户编号", required = true, example = "1024")
+ private Long userId;
+ @ApiModelProperty(value = "用户类型", required = true, example = "1")
+ private Integer userType;
+ @ApiModelProperty(value = "应用名", required = true, example = "system-server")
+ @NotNull(message = "应用名不能为空")
+ private String applicationName;
+
+ @ApiModelProperty(value = "请求方法名", required = true, example = "GET")
+ @NotNull(message = "http 请求方法不能为空")
+ private String requestMethod;
+ @ApiModelProperty(value = "请求地址", required = true, example = "/xxx/yyy")
+ @NotNull(message = "访问地址不能为空")
+ private String requestUrl;
+ @ApiModelProperty(value = "请求参数", required = true)
+ @NotNull(message = "请求参数不能为空")
+ private String requestParams;
+ @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1")
+ @NotNull(message = "ip 不能为空")
+ private String userIp;
+ @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0")
+ @NotNull(message = "User-Agent 不能为空")
+ private String userAgent;
+
+ @ApiModelProperty(value = "开始时间", required = true)
+ @NotNull(message = "开始请求时间不能为空")
+ private Date beginTime;
+ @ApiModelProperty(value = "结束时间", required = true)
+ @NotNull(message = "结束请求时间不能为空")
+ private Date endTime;
+ @ApiModelProperty(value = "执行时长,单位:毫秒", required = true)
+ @NotNull(message = "执行时长不能为空")
+ private Integer duration;
+ @ApiModelProperty(value = "结果码", required = true)
+ @NotNull(message = "错误码不能为空")
+ private Integer resultCode;
+ @ApiModelProperty(value = "结果提示")
+ private String resultMsg;
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java
new file mode 100644
index 000000000..1e9c4933e
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java
@@ -0,0 +1,69 @@
+package cn.iocoder.yudao.module.infra.api.logger.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+@ApiModel("API 错误日志创建 Request DTO")
+@Data
+public class ApiErrorLogCreateReqDTO {
+
+ @ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
+ private String traceId;
+
+ @ApiModelProperty(value = "用户编号", required = true, example = "1024")
+ private Long userId;
+ @ApiModelProperty(value = "用户类型", required = true, example = "1")
+ private Integer userType;
+ @ApiModelProperty(value = "应用名", required = true, example = "system-server")
+ @NotNull(message = "应用名不能为空")
+ private String applicationName;
+
+ @ApiModelProperty(value = "请求方法名", required = true, example = "GET")
+ @NotNull(message = "http 请求方法不能为空")
+ private String requestMethod;
+ @ApiModelProperty(value = "请求地址", required = true, example = "/xxx/yyy")
+ @NotNull(message = "访问地址不能为空")
+ private String requestUrl;
+ @ApiModelProperty(value = "请求参数", required = true)
+ @NotNull(message = "请求参数不能为空")
+ private String requestParams;
+ @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1")
+ @NotNull(message = "ip 不能为空")
+ private String userIp;
+ @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0")
+ @NotNull(message = "User-Agent 不能为空")
+ private String userAgent;
+
+ @ApiModelProperty(value = "异常时间", required = true)
+ @NotNull(message = "异常时间不能为空")
+ private Date exceptionTime;
+ @ApiModelProperty(value = "异常名", required = true)
+ @NotNull(message = "异常名不能为空")
+ private String exceptionName;
+ @ApiModelProperty(value = "异常发生的类全名", required = true)
+ @NotNull(message = "异常发生的类全名不能为空")
+ private String exceptionClassName;
+ @ApiModelProperty(value = "异常发生的类文件", required = true)
+ @NotNull(message = "异常发生的类文件不能为空")
+ private String exceptionFileName;
+ @ApiModelProperty(value = "异常发生的方法名", required = true)
+ @NotNull(message = "异常发生的方法名不能为空")
+ private String exceptionMethodName;
+ @ApiModelProperty(value = "异常发生的方法所在行", required = true)
+ @NotNull(message = "异常发生的方法所在行不能为空")
+ private Integer exceptionLineNumber;
+ @ApiModelProperty(value = "异常的栈轨迹异常的栈轨迹", required = true)
+ @NotNull(message = "异常的栈轨迹不能为空")
+ private String exceptionStackTrace;
+ @ApiModelProperty(value = "异常导致的根消息", required = true)
+ @NotNull(message = "异常导致的根消息不能为空")
+ private String exceptionRootCauseMessage;
+ @ApiModelProperty(value = "异常导致的消息", required = true)
+ @NotNull(message = "异常导致的消息不能为空")
+ private String exceptionMessage;
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ApiConstants.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ApiConstants.java
index 7f02d0161..d0f6f5f86 100644
--- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ApiConstants.java
+++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ApiConstants.java
@@ -16,7 +16,7 @@ public class ApiConstants {
*/
public static final String NAME = "infra-server";
- public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/system";
+ public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/infra";
public static final String VERSION = "1.0.0";
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java
new file mode 100644
index 000000000..a54bc27a9
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.infra.api.logger;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.module.system.enums.ApiConstants.VERSION;
+
+@RestController // 提供 RESTful API 接口,给 Feign 调用
+@DubboService(version = VERSION) // 提供 Dubbo RPC 接口,给 Dubbo Consumer 调用
+@Validated
+public class ApiAccessLogApiImpl implements ApiAccessLogApi {
+
+ @Resource
+ private ApiAccessLogService apiAccessLogService;
+
+ @Override
+ public CommonResult createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
+ apiAccessLogService.createApiAccessLog(createDTO);
+ return success(true);
+ }
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java
new file mode 100644
index 000000000..5e8d8dbed
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java
@@ -0,0 +1,31 @@
+package cn.iocoder.yudao.module.infra.api.logger;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
+import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
+import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.module.system.enums.ApiConstants.VERSION;
+
+@RestController // 提供 RESTful API 接口,给 Feign 调用
+@DubboService(version = VERSION) // 提供 Dubbo RPC 接口,给 Dubbo Consumer 调用
+@Validated
+public class ApiErrorLogApiImpl implements ApiErrorLogApi {
+
+ @Resource
+ private ApiErrorLogService apiErrorLogService;
+
+ @Override
+ public CommonResult createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
+ apiErrorLogService.createApiErrorLog(createDTO);
+ return success(true);
+ }
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.http b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.http
index 4ef955f44..61dede43f 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.http
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.http
@@ -39,7 +39,7 @@ Authorization: Bearer {{token}}
}
### 请求 /infra/file-config/test 接口 => 成功
-GET {{baseUrl}}/infra/file-config/test?id=2
+GET {{infaBaseUrl}}/infra/file-config/test?id=2
Content-Type: application/json
tenant-id: {{adminTenentId}}
Authorization: Bearer {{token}}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java
index 7162d4d9a..03232bc75 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java
@@ -1,7 +1,8 @@
package cn.iocoder.yudao.module.infra.convert.logger;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExcelVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java
index 8eef7463a..fb3a21d8c 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java
@@ -1,7 +1,8 @@
package cn.iocoder.yudao.module.infra.convert.logger;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExcelVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
index 048411769..306511206 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.infra.framework.security.config;
import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer;
+import cn.iocoder.yudao.module.infra.enums.ApiConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -37,6 +38,10 @@ public class SecurityConfiguration {
.antMatchers(adminSeverContextPath + "/**").anonymous();
// 文件的获取接口,可匿名访问
registry.antMatchers(buildAdminApi("/infra/file/*/get/**"), buildAppApi("/infra/file/get/**")).permitAll();
+
+ // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案
+ // RPC 服务的安全配置
+ registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll();
}
};
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
index 22aea79b4..e8159cf62 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.infra.service.logger;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -13,7 +15,14 @@ import java.util.List;
*
* @author 芋道源码
*/
-public interface ApiAccessLogService extends ApiAccessLogFrameworkService {
+public interface ApiAccessLogService {
+
+ /**
+ * 创建 API 访问日志
+ *
+ * @param createReqDTO API 访问日志
+ */
+ void createApiAccessLog(ApiAccessLogCreateReqDTO createReqDTO);
/**
* 获得 API 访问日志分页
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
index 64df85ac0..a2311dc94 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.infra.service.logger;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert;
@@ -26,6 +27,12 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
@Resource
private ApiAccessLogMapper apiAccessLogMapper;
+ @Override
+ public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
+ ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO);
+ apiAccessLogMapper.insert(apiAccessLog);
+ }
+
@Override
public PageResult getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) {
return apiAccessLogMapper.selectPage(pageReqVO);
@@ -36,11 +43,4 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
return apiAccessLogMapper.selectList(exportReqVO);
}
- @Override
- @Async
- public void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
- ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO);
- apiAccessLogMapper.insert(apiAccessLog);
- }
-
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
index 2ad0479fe..b30d438a0 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
@@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.infra.service.logger;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
@@ -13,7 +15,14 @@ import java.util.List;
*
* @author 芋道源码
*/
-public interface ApiErrorLogService extends ApiErrorLogFrameworkService {
+public interface ApiErrorLogService {
+
+ /**
+ * 创建 API 错误日志
+ *
+ * @param createReqDTO API 错误日志
+ */
+ void createApiErrorLog(ApiErrorLogCreateReqDTO createReqDTO);
/**
* 获得 API 错误日志分页
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
index 038f47a38..7e0cc3d85 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.infra.service.logger;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
@@ -30,6 +31,13 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
@Resource
private ApiErrorLogMapper apiErrorLogMapper;
+ @Override
+ public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
+ ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO);
+ apiErrorLog.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
+ apiErrorLogMapper.insert(apiErrorLog);
+ }
+
@Override
public PageResult getApiErrorLogPage(ApiErrorLogPageReqVO pageReqVO) {
return apiErrorLogMapper.selectPage(pageReqVO);
@@ -54,12 +62,4 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
.processUserId(processUserId).processTime(new Date()).build());
}
- @Override
- @Async
- public void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
- ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO);
- apiErrorLog.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
- apiErrorLogMapper.insert(apiErrorLog);
- }
-
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
index 7ae75d9c4..1aa699042 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
@@ -1,13 +1,14 @@
package cn.iocoder.yudao.module.infra.service.logger;
import cn.hutool.core.util.RandomUtil;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
@@ -149,13 +150,13 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
}
@Test
- public void testCreateApiAccessLogAsync() {
+ public void testCreateApiAccessLog() {
// 准备参数
ApiAccessLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateReqDTO.class,
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
// 调用
- apiAccessLogService.createApiAccessLogAsync(createDTO);
+ apiAccessLogService.createApiAccessLog(createDTO);
// 断言
ApiAccessLogDO infApiAccessLogDO = apiAccessLogMapper.selectOne(null);
assertNotNull(infApiAccessLogDO);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
index 6c08af886..6fdd7a368 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
@@ -1,12 +1,13 @@
package cn.iocoder.yudao.module.infra.service.logger;
import cn.hutool.core.util.RandomUtil;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
+import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
@@ -181,13 +182,13 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
}
@Test
- public void testCreateApiErrorLogAsync() {
+ public void testCreateApiErrorLog() {
// 准备参数
ApiErrorLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateReqDTO.class,
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
// 调用
- apiErrorLogService.createApiErrorLogAsync(createDTO);
+ apiErrorLogService.createApiErrorLog(createDTO);
// 断言
ApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null);
assertNotNull(infApiErrorLogDO);
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java
index b63a3ea44..dc6acef3a 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java
@@ -13,7 +13,7 @@ import java.util.Map;
@Data
public class OperateLogCreateReqDTO {
- @ApiModelProperty(value = "链路追踪编号", required = true, example = "89aca178-a370-411c-ae02-3f0d672be4ab")
+ @ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
private String traceId;
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/TmpConfiguration.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/TmpConfiguration.java
index 51e4ff417..2386654e6 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/TmpConfiguration.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/TmpConfiguration.java
@@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.system.framework;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
+import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
-import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -25,7 +25,7 @@ public class TmpConfiguration {
public ApiAccessLogFrameworkService apiAccessLogFrameworkService() {
return new ApiAccessLogFrameworkService() {
@Override
- public void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
+ public void createApiAccessLog(ApiAccessLog apiAccessLog) {
}
};
@@ -35,7 +35,7 @@ public class TmpConfiguration {
public ApiErrorLogFrameworkService apiErrorLogFrameworkService() {
return new ApiErrorLogFrameworkService() {
@Override
- public void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
+ public void createApiErrorLog(ApiErrorLog apiErrorLog) {
}
};