优化 yudao-spring-boot-starter-web 的 API 日志封装,和 yudao-cloud 保持一致
This commit is contained in:
parent
284ee5000a
commit
4c6e915def
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -53,13 +53,26 @@
|
||||
<scope>provided</scope> <!-- 设置为 provided,主要是 GlobalExceptionHandler 使用 -->
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 远程调用相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-rpc</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-module-infra-api</artifactId> <!-- 需要使用它,进行操作日志的记录 -->
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 服务保障相关 -->
|
||||
<dependency>
|
||||
<groupId>io.github.resilience4j</groupId>
|
||||
<artifactId>resilience4j-ratelimiter</artifactId>
|
||||
<scope>provided</scope> <!-- 设置为 provided,主要是 GlobalExceptionHandler 使用 -->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -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 请求日志
|
||||
*/
|
||||
|
@ -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 {
|
||||
}
|
@ -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<String, String> 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<String, String> queryString, String requestBody, Exception ex) {
|
||||
// 处理用户信息
|
||||
accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
|
||||
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 链路追踪编号
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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<Boolean> result = apiAccessLogApi.createApiAccessLog(reqDTO);
|
||||
result.checkError();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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<Boolean> result = apiErrorLogApi.createApiErrorLog(reqDTO);
|
||||
result.checkError();
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
|
@ -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,\
|
||||
|
@ -21,6 +21,27 @@
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 远程调用相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -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<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
||||
|
||||
}
|
@ -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<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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";
|
||||
|
||||
|
@ -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<Boolean> createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
|
||||
apiAccessLogService.createApiAccessLog(createDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
@ -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<Boolean> createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
|
||||
apiErrorLogService.createApiErrorLog(createDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
@ -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}}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -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 访问日志分页
|
||||
|
@ -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<ApiAccessLogDO> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 错误日志分页
|
||||
|
@ -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<ApiErrorLogDO> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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")
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user