mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-03 19:16:21 +00:00
feat 日志模块
This commit is contained in:
@@ -3,7 +3,7 @@ package cn.bootx.platform.common.cache.configuration;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
26
bootx-platform/bootx-platform-common/common-log/pom.xml
Normal file
26
bootx-platform/bootx-platform-common/common-log/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>bootx-platform-common</artifactId>
|
||||
<version>3.0.0.beta1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-log</artifactId>
|
||||
<description>日志模块</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,17 @@
|
||||
package cn.bootx.platform.common.log;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 日志扫描
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2022/6/6
|
||||
*/
|
||||
@ComponentScan
|
||||
@ConfigurationPropertiesScan
|
||||
@AutoConfiguration
|
||||
public class LogAutoConfigurationLogAutoConfiguration {
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package cn.bootx.platform.common.log.handler;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 针对请求生成链路追踪ID
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/4/20
|
||||
*/
|
||||
@Order(value = Integer.MIN_VALUE)
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public class LogTraceHeaderHolderFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
String traceId = RandomUtil.randomString(12);
|
||||
// 添加普通日志 TraceId
|
||||
MDC.put(CommonCode.TRACE_ID, traceId);
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
finally {
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1 @@
|
||||
cn.bootx.platform.common.log.LogAutoConfigurationLogAutoConfiguration
|
@@ -23,6 +23,7 @@
|
||||
<module>common-header-holder</module>
|
||||
<module>common-redis</module>
|
||||
<module>common-cache</module>
|
||||
<module>common-log</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -95,6 +95,13 @@
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 日志模块 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@@ -8,8 +8,10 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -20,6 +22,7 @@ import java.nio.charset.StandardCharsets;
|
||||
* @author xxm
|
||||
* @since 2023/10/14
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "系统基础接口")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -43,7 +46,7 @@ public class BaseController {
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "读取文件文本内容")
|
||||
@PostMapping("/readText")
|
||||
public Result<String> readText(MultipartFile file){
|
||||
public Result<String> readText(@RequestPart MultipartFile file){
|
||||
return Res.ok(new String(file.getBytes(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@@ -11,7 +11,7 @@ import cn.hutool.core.util.DesensitizedUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
@@ -6,7 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@@ -27,6 +27,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -89,7 +90,7 @@ public class FileUploadService {
|
||||
* @param fileName 文件名称
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public UploadFileResult upload(MultipartFile file, String fileName) {
|
||||
public UploadFileResult upload(@RequestPart MultipartFile file, String fileName) {
|
||||
UploadPretreatment uploadPretreatment = fileStorageService.of(file);
|
||||
if (StrUtil.isNotBlank(fileName)){
|
||||
uploadPretreatment.setOriginalFilename(fileName);
|
||||
|
Reference in New Issue
Block a user