From 3276ad007452566cd0b3c64353e80a5eb8b20b52 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 14 Jun 2022 23:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20yudao-spring-boot-starter-?= =?UTF-8?q?web=20=E7=9A=84=20API=20=E6=97=A5=E5=BF=97=E5=B0=81=E8=A3=85?= =?UTF-8?q?=EF=BC=8C=E5=92=8C=20yudao-cloud=20=E4=BF=9D=E6=8C=81=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-spring-boot-starter-web/pom.xml | 7 ++ .../config/YudaoApiLogAutoConfiguration.java | 17 ++- .../core/filter/ApiAccessLogFilter.java | 8 +- .../apilog/core/service/ApiAccessLog.java | 85 ++++++++++++++ .../service/ApiAccessLogFrameworkService.java | 8 +- .../ApiAccessLogFrameworkServiceImpl.java | 28 +++++ .../apilog/core/service/ApiErrorLog.java | 107 ++++++++++++++++++ .../service/ApiErrorLogFrameworkService.java | 8 +- .../ApiErrorLogFrameworkServiceImpl.java | 28 +++++ .../core/handler/GlobalExceptionHandler.java | 14 +-- .../yudao-module-infra-api/pom.xml | 7 ++ .../infra/api/logger/ApiAccessLogApi.java | 21 ++++ .../infra/api/logger/ApiErrorLogApi.java | 21 ++++ .../logger}/dto/ApiAccessLogCreateReqDTO.java | 4 +- .../logger}/dto/ApiErrorLogCreateReqDTO.java | 7 +- .../infra/api/logger/ApiAccessLogApiImpl.java | 27 +++++ .../infra/api/logger/ApiErrorLogApiImpl.java | 27 +++++ .../convert/logger/ApiAccessLogConvert.java | 2 +- .../convert/logger/ApiErrorLogConvert.java | 2 +- .../service/logger/ApiAccessLogService.java | 13 ++- .../logger/ApiAccessLogServiceImpl.java | 18 ++- .../service/logger/ApiErrorLogService.java | 11 +- .../logger/ApiErrorLogServiceImpl.java | 22 ++-- .../logger/ApiAccessLogServiceImplTest.java | 4 +- .../logger/ApiErrorLogServiceImplTest.java | 4 +- 25 files changed, 437 insertions(+), 63 deletions(-) create mode 100644 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java create mode 100644 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java create mode 100644 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java create mode 100644 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java create mode 100644 yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java create mode 100644 yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java rename {yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service => yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger}/dto/ApiAccessLogCreateReqDTO.java (94%) rename {yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service => yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger}/dto/ApiErrorLogCreateReqDTO.java (93%) create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml index 44081d86b..8662584e3 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml @@ -53,6 +53,13 @@ provided + + + cn.iocoder.boot + yudao-module-infra-api + ${revision} + + io.github.resilience4j 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..2d4273e5f 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.common.enums.WebFilterOrderEnum; 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/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/ApiAccessLog.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java new file mode 100644 index 000000000..a92b06c26 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * API 访问日志 + * + * @author 芋道源码 + */ +@Data +public class ApiAccessLog { + + /** + * 链路追踪编号 + */ + private String traceId; + /** + * 用户编号 + */ + private Long userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + @NotNull(message = "应用名不能为空") + private String applicationName; + + /** + * 请求方法名 + */ + @NotNull(message = "http 请求方法不能为空") + private String requestMethod; + /** + * 访问地址 + */ + @NotNull(message = "访问地址不能为空") + private String requestUrl; + /** + * 请求参数 + */ + @NotNull(message = "请求参数不能为空") + private String requestParams; + /** + * 用户 IP + */ + @NotNull(message = "ip 不能为空") + private String userIp; + /** + * 浏览器 UA + */ + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + + /** + * 开始请求时间 + */ + @NotNull(message = "开始请求时间不能为空") + private Date beginTime; + /** + * 结束请求时间 + */ + @NotNull(message = "结束请求时间不能为空") + private Date endTime; + /** + * 执行时长,单位:毫秒 + */ + @NotNull(message = "执行时长不能为空") + private Integer duration; + /** + * 结果码 + */ + @NotNull(message = "错误码不能为空") + private Integer resultCode; + /** + * 结果提示 + */ + private String resultMsg; + +} 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..83162f164 --- /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,28 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import cn.hutool.core.bean.BeanUtil; +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); + apiAccessLogApi.createApiAccessLog(reqDTO); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java new file mode 100644 index 000000000..3f5d539cb --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * API 错误日志 + * + * @author 芋道源码 + */ +@Data +public class ApiErrorLog { + + /** + * 链路编号 + */ + private String traceId; + /** + * 账号编号 + */ + private Long userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + @NotNull(message = "应用名不能为空") + private String applicationName; + + /** + * 请求方法名 + */ + @NotNull(message = "http 请求方法不能为空") + private String requestMethod; + /** + * 访问地址 + */ + @NotNull(message = "访问地址不能为空") + private String requestUrl; + /** + * 请求参数 + */ + @NotNull(message = "请求参数不能为空") + private String requestParams; + /** + * 用户 IP + */ + @NotNull(message = "ip 不能为空") + private String userIp; + /** + * 浏览器 UA + */ + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + + /** + * 异常时间 + */ + @NotNull(message = "异常时间不能为空") + private Date exceptionTime; + /** + * 异常名 + */ + @NotNull(message = "异常名不能为空") + private String exceptionName; + /** + * 异常发生的类全名 + */ + @NotNull(message = "异常发生的类全名不能为空") + private String exceptionClassName; + /** + * 异常发生的类文件 + */ + @NotNull(message = "异常发生的类文件不能为空") + private String exceptionFileName; + /** + * 异常发生的方法名 + */ + @NotNull(message = "异常发生的方法名不能为空") + private String exceptionMethodName; + /** + * 异常发生的方法所在行 + */ + @NotNull(message = "异常发生的方法所在行不能为空") + private Integer exceptionLineNumber; + /** + * 异常的栈轨迹异常的栈轨迹 + */ + @NotNull(message = "异常的栈轨迹不能为空") + private String exceptionStackTrace; + /** + * 异常导致的根消息 + */ + @NotNull(message = "异常导致的根消息不能为空") + private String exceptionRootCauseMessage; + /** + * 异常导致的消息 + */ + @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..cb5abe3c2 --- /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,28 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import cn.hutool.core.bean.BeanUtil; +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); + apiErrorLogApi.createApiErrorLog(reqDTO); + } + +} 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 578ad76f9..7a0fe6be7 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,14 +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.apilog.core.service.ApiErrorLogFrameworkService; 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.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import io.github.resilience4j.ratelimiter.RequestNotPermitted; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -229,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-module-infra/yudao-module-infra-api/pom.xml b/yudao-module-infra/yudao-module-infra-api/pom.xml index f194e82b0..168ea645b 100644 --- a/yudao-module-infra/yudao-module-infra-api/pom.xml +++ b/yudao-module-infra/yudao-module-infra-api/pom.xml @@ -21,6 +21,13 @@ cn.iocoder.boot yudao-common + + + + org.springframework.boot + spring-boot-starter-validation + 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..ed3f3ee1e --- /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,21 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; + +import javax.validation.Valid; + +/** + * API 访问日志的 API 接口 + * + * @author 芋道源码 + */ +public interface ApiAccessLogApi { + + /** + * 创建 API 访问日志 + * + * @param createDTO 创建信息 + */ + void createApiAccessLog(@Valid 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..9b53c6643 --- /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,21 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; + +import javax.validation.Valid; + +/** + * API 错误日志的 API 接口 + * + * @author 芋道源码 + */ +public interface ApiErrorLogApi { + + /** + * 创建 API 错误日志 + * + * @param createDTO 创建信息 + */ + void createApiErrorLog(@Valid ApiErrorLogCreateReqDTO createDTO); + +} 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-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java similarity index 94% 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-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java index a32f7b346..0ad0ea79c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.apilog.core.service.dto; +package cn.iocoder.yudao.module.infra.api.logger.dto; import lombok.Data; @@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull; import java.util.Date; /** - * API 访问日志创建 DTO + * API 访问日志 * * @author 芋道源码 */ 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-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java similarity index 93% 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-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java index 70baebc5c..c2d555703 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java @@ -1,18 +1,16 @@ -package cn.iocoder.yudao.framework.apilog.core.service.dto; +package cn.iocoder.yudao.module.infra.api.logger.dto; 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 { /** @@ -105,4 +103,5 @@ public class ApiErrorLogCreateReqDTO { @NotNull(message = "异常导致的消息不能为空") private String exceptionMessage; + } 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..2daa4a1c4 --- /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,27 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * API 访问日志的 API 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ApiAccessLogApiImpl implements ApiAccessLogApi { + + @Resource + private ApiAccessLogService apiAccessLogService; + + @Override + public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) { + apiAccessLogService.createApiAccessLog(createDTO); + } + +} 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..cdb0ec293 --- /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,27 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * API 访问日志的 API 接口 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ApiErrorLogApiImpl implements ApiErrorLogApi { + + @Resource + private ApiErrorLogService apiErrorLogService; + + @Override + public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) { + apiErrorLogService.createApiErrorLog(createDTO); + } + +} 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..f3a80e8c0 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,7 @@ package cn.iocoder.yudao.module.infra.convert.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; 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..778e171c7 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,7 @@ package cn.iocoder.yudao.module.infra.convert.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; 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/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..e473b2322 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,9 +1,9 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; +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.ApiAccessLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; import java.util.List; @@ -13,7 +13,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..e3b3234ee 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,13 +1,12 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; +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.ApiAccessLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -26,6 +25,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 +41,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..138c9bef4 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,7 @@ package cn.iocoder.yudao.module.infra.service.logger; -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 +13,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..d265f09f6 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,16 +1,15 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; +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.convert.logger.ApiErrorLogConvert; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -30,6 +29,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 +60,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..5f00b3bf5 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,13 @@ 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.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; @@ -155,7 +155,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { 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..fbe9ebc05 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,12 @@ 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.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; @@ -187,7 +187,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); // 调用 - apiErrorLogService.createApiErrorLogAsync(createDTO); + apiErrorLogService.createApiErrorLog(createDTO); // 断言 ApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null); assertNotNull(infApiErrorLogDO);