weijianghai 6 сар өмнө
parent
commit
c07b012826

+ 0 - 6
pom.xml

@@ -48,12 +48,6 @@
             <artifactId>commons-exec</artifactId>
             <version>1.3</version>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.10.1</version>
-        </dependency>
         <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
         <dependency>
             <groupId>com.baomidou</groupId>

+ 0 - 61
src/main/java/com/example/config/web/MyDispatcherServlet.java

@@ -1,61 +0,0 @@
-package com.example.config.web;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.servlet.DispatcherServlet;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-@Slf4j
-public class MyDispatcherServlet extends DispatcherServlet {
-    /**
-     * 上传和返回文件流的接口uri,不替换request和response
-     */
-    public static final Set<String> UN_WRAPPER = Stream.of(
-            "/house-car/house/dist/api/data-import/dataImport",
-            "/house-car/house/dist/api/WzBuildManageDetails/ideListExport",
-            "/house-car/house/dist/api/WzBuildManageDetails/queryHouseDetailExport",
-            "/house-car/house/dist/api/WzBuildManageDetails/queryHouseYearExport",
-            "/house-car/house/dist/api/WzBuildManageDetails/buildingIdleStatExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/queryHighPriceExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/queryHighFrequencyExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/queryDailyModifyExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/buildingIdleRepairExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/buildingRepairStatExport",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/listBuildingRepairMonthExport",
-            "/house-car/house/dist/api/WzHouseLeaseInCon/rentInContractStatExport",
-            "/house-car/house/dist/api/WzHouseContractIn/listRentInContractExport",
-            "/house-car/house/dist/api/WzHouseUse/rentInUseStatExport",
-            "/house-car/house/dist/api/WzHouseContractTop/listRentInTopExport",
-            "/house-car/house/dist/api/WzHouseContractCompare/listRentInCompareExport",
-            "/house-car/house/dist/api/siteStat/siteStatExport",
-            "/house-car/house/dist/api/WzBuildmanageAvagearea/buildingOfficeAreaStatExport",
-            "/house-car/house/dist/api/WzBuildManageDetails/excel",
-            "/house-car/house/dist/api/WzHouseContractOut/excel",
-            "/house-car/house/dist/api/WzHouseContrac/excel",
-            "/house-car/house/dist/api/WzHouseLeaseInCon/excel",
-            "/house-car/house/dist/api/wzHouseMaintenaCost/excel",
-            "/house-car/house/dist/api/WzHouseUse/excel",
-            "/house-car/house/dist/api/WzLandManageDetails/excel",
-            "/house-car/house/dist/api/wzLowestUnitPrice/excel",
-            "/house-car/house/dist/api/wzRentHouseArrears/excel",
-            "/house-car/house/dist/api/wzRentThreeMonth/excel",
-            "/house-car/house/dist/api/wzScoreRanking/excel",
-            "/house-car/house/dist/api/WzBuildManageDetails/loadWord"
-    ).collect(Collectors.toSet());
-
-    @Override
-    protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
-        String uri = request.getRequestURI();
-        if (UN_WRAPPER.contains(request.getRequestURI())) {
-            super.doDispatch(request, response);
-        } else {
-            // 替换request和response
-            log.info("替换 {} 的request和response", uri);
-            super.doDispatch(new MyHttpServletRequestWrapper(request), new MyHttpServletResponseWrapper(response));
-        }
-    }
-}

+ 0 - 58
src/main/java/com/example/config/web/MyHttpServletRequestWrapper.java

@@ -1,58 +0,0 @@
-package com.example.config.web;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.util.StreamUtils;
-
-import javax.servlet.ReadListener;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-
-/**
- * 解决流只能读取一次问题
- */
-@Slf4j
-public class MyHttpServletRequestWrapper extends HttpServletRequestWrapper {
-    private byte[] bytes;
-
-    public MyHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
-        super(request);
-        bytes = StreamUtils.copyToByteArray(request.getInputStream());
-    }
-
-    @Override
-    public ServletInputStream getInputStream() {
-        ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
-        return new ServletInputStream() {
-            @Override
-            public boolean isFinished() {
-                return false;
-            }
-
-            @Override
-            public boolean isReady() {
-                return false;
-            }
-
-            @Override
-            public void setReadListener(ReadListener readListener) {
-                //
-            }
-
-            @Override
-            public int read() {
-                return stream.read();
-            }
-        };
-    }
-
-    @Override
-    public BufferedReader getReader() throws UnsupportedEncodingException {
-        return new BufferedReader(new InputStreamReader(getInputStream(), super.getCharacterEncoding()));
-    }
-}

+ 0 - 47
src/main/java/com/example/config/web/MyHttpServletResponseWrapper.java

@@ -1,47 +0,0 @@
-package com.example.config.web;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-/**
- * 解决流只能读取一次问题
- */
-public class MyHttpServletResponseWrapper extends HttpServletResponseWrapper {
-    private ByteArrayOutputStream byteArrayOutputStream;
-    private ServletOutputStream servletOutputStream;
-
-    public MyHttpServletResponseWrapper(HttpServletResponse response) {
-        super(response);
-        byteArrayOutputStream = new ByteArrayOutputStream();
-        servletOutputStream = new ServletOutputStream() {
-            @Override
-            public boolean isReady() {
-                return false;
-            }
-
-            @Override
-            public void setWriteListener(WriteListener writeListener) {
-                //
-            }
-
-            @Override
-            public void write(int b) throws IOException {
-                response.getOutputStream().write(b);
-                byteArrayOutputStream.write(b);
-            }
-        };
-    }
-
-    @Override
-    public ServletOutputStream getOutputStream() {
-        return servletOutputStream;
-    }
-
-    public byte[] toByteArray() {
-        return byteArrayOutputStream.toByteArray();
-    }
-}

+ 6 - 21
src/main/java/com/example/config/web/MyWebMvcConfigurer.java

@@ -1,36 +1,21 @@
 package com.example.config.web;
 
-import com.example.service.common.RequestLogService;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
-import org.springframework.context.annotation.Bean;
+import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.DispatcherServlet;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 @Configuration
+@RequiredArgsConstructor
 public class MyWebMvcConfigurer implements WebMvcConfigurer {
-    private final RequestLogService requestLogService;
-
-    public MyWebMvcConfigurer(RequestLogService requestLogService) {
-        this.requestLogService = requestLogService;
-    }
+    private final RequestLogHandlerInterceptor requestLogHandlerInterceptor;
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         // 添加请求日志拦截
-        registry.addInterceptor(new RequestLogHandlerInterceptor(requestLogService))
-                .addPathPatterns("/**").excludePathPatterns("/webjars/**", "/doc**", "/v3/**", "/test/**");
-    }
-
-    /**
-     * 使用自定义DispatcherServlet
-     */
-    @Bean
-    @Qualifier(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
-    public DispatcherServlet dispatcherServlet() {
-        return new MyDispatcherServlet();
+        registry.addInterceptor(requestLogHandlerInterceptor)
+                .addPathPatterns("/**")
+                .excludePathPatterns("/webjars/**", "/v3/**", "/doc.html", "/favicon.ico", "/test/**");
     }
 
 //    /**

+ 93 - 43
src/main/java/com/example/config/web/RequestLogHandlerInterceptor.java

@@ -5,21 +5,29 @@ import com.example.service.common.RequestLogService;
 import com.example.utils.AESUtil;
 import com.example.utils.R;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
+import org.springframework.core.MethodParameter;
+import org.springframework.http.HttpInputMessage;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
 import org.springframework.lang.Nullable;
 import org.springframework.util.StopWatch;
-import org.springframework.util.StreamUtils;
 import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.lang.reflect.Type;
 import java.net.URLDecoder;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -32,16 +40,16 @@ import java.util.UUID;
  * 请求日志拦截器
  */
 @Slf4j
-public class RequestLogHandlerInterceptor implements HandlerInterceptor {
+@ControllerAdvice
+@RequiredArgsConstructor
+public class RequestLogHandlerInterceptor implements HandlerInterceptor, RequestBodyAdvice, ResponseBodyAdvice<Object> {
     /**
      * 计时器线程变量
      */
     private static final ThreadLocal<StopWatch> STOP_WATCH_THREAD_LOCAL = new ThreadLocal<>();
-    private RequestLogService requestLogService;
-
-    public RequestLogHandlerInterceptor(RequestLogService requestLogService) {
-        this.requestLogService = requestLogService;
-    }
+    private static final ThreadLocal<RequestLogPo> REQUEST_LOG_PO_THREAD_LOCAL = new ThreadLocal<>();
+    private final RequestLogService requestLogService;
+    private final ObjectMapper objectMapper;
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -71,12 +79,6 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor {
             parameters.put(k, v);
         }
         log.info("查询参数: {}", new ObjectMapper().writeValueAsString(parameters));
-        String body = null;
-        if (!MyDispatcherServlet.UN_WRAPPER.contains(request.getRequestURI())) {
-            // 请求体参数
-            body = StreamUtils.copyToString(request.getInputStream(), Charset.forName(request.getCharacterEncoding()));
-            log.info("请求体参数: {}", StringUtils.trimAllWhitespace(body));
-        }
         String token = request.getHeader("token");
         if (!StringUtils.hasText(token) || "undefined".equals(token)) {
             token = parameters.get("token");
@@ -90,9 +92,8 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor {
             log.info("urlDecodeToken: {}", urlDecodeToken);
             String decryptToken = AESUtil.decrypt(urlDecodeToken);
             log.info("decryptToken: {}", decryptToken);
-            Gson gson = new Gson();
-            Map<String, String> map = gson.fromJson(decryptToken, new TypeToken<Map<String, String>>() {
-            }.getType());
+            Map<String, String> map = objectMapper.readValue(decryptToken,
+                    TypeFactory.defaultInstance().constructMapType(Map.class, String.class, String.class));
             if (!"FINANCE".equals(map.get("APP_ID"))
                     || !StringUtils.hasText(map.get("LOGIN_ID"))
                     || !StringUtils.hasText(map.get("TIME_STAMP"))
@@ -109,21 +110,20 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor {
                 return unauthorized(response);
             }
             Map<String, String> requestParameters = new HashMap<>();
-            requestParameters.put("request_parameters", gson.toJson(parameters));
-            requestParameters.put("request_body", body);
+            requestParameters.put("request_parameters", objectMapper.writeValueAsString(parameters));
             RequestLogPo requestLogPo = new RequestLogPo();
+            REQUEST_LOG_PO_THREAD_LOCAL.set(requestLogPo);
             requestLogPo.setRequestTime(now);
             requestLogPo.setLoginId(map.get("LOGIN_ID"));
             requestLogPo.setPageUrl(map.get("REQUEST_URL"));
             requestLogPo.setApi(request.getRequestURI());
-            requestLogPo.setRequestParameters(gson.toJson(requestParameters));
-            requestLogPo.setHeaders(gson.toJson(headers));
+            requestLogPo.setRequestParameters(objectMapper.writeValueAsString(requestParameters));
+            requestLogPo.setHeaders(objectMapper.writeValueAsString(headers));
             requestLogPo.setAppId(map.get("APP_ID"));
             requestLogPo.setToken(urlDecodeToken);
             requestLogPo.setTimeStamp(timeStamp);
             requestLogPo.setExpireTime(expireTime);
             requestLogPo.setExpireTimeStamp(expireTimeStamp);
-            requestLogService.offer(requestLogPo);
         } catch (Exception e) {
             log.error("token解密失败: {} {}", token, e.getMessage(), e);
             return forbidden(response);
@@ -134,47 +134,97 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor {
     @Override
     public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
                                 @Nullable Exception ex) throws Exception {
-        if (!MyDispatcherServlet.UN_WRAPPER.contains(request.getRequestURI())) {
-            MyHttpServletResponseWrapper wrapper = (MyHttpServletResponseWrapper) response;
-            String responseString = new String(wrapper.toByteArray());
-//            log.info("响应 {}: {}", wrapper.getStatus(), responseString);
-            // 返回结果打印前500个字符
-            log.info("返回 {}: {}", wrapper.getStatus(),
-                    org.apache.commons.lang3.StringUtils.substring(responseString, 0, 500));
-        } else {
-            log.info("响应 {}", response.getStatus());
-        }
+        log.info("响应状态: {}", response.getStatus());
         StopWatch stopWatch = STOP_WATCH_THREAD_LOCAL.get();
         stopWatch.stop();
-        log.info("耗时 {} ms", stopWatch.getTotalTimeMillis());
+        log.info("耗时: {} ms", stopWatch.getTotalTimeMillis());
         STOP_WATCH_THREAD_LOCAL.remove();
+        RequestLogPo requestLogPo = REQUEST_LOG_PO_THREAD_LOCAL.get();
+        if (requestLogPo != null) {
+            requestLogService.offer(requestLogPo);
+        }
+        REQUEST_LOG_PO_THREAD_LOCAL.remove();
     }
 
     private boolean forbidden(HttpServletResponse response) throws IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        String r = new Gson().toJson(R.error(403, "没有权限访问"));
+        response.setCharacterEncoding(StandardCharsets.UTF_8.name());
+        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
+        String r = objectMapper.writeValueAsString(R.error(403, "没有权限访问"));
         byte[] bytes = r.getBytes();
         response.getOutputStream().write(bytes);
         StopWatch stopWatch = STOP_WATCH_THREAD_LOCAL.get();
         stopWatch.stop();
-        log.warn("返回 {}: {}", response.getStatus(), r);
+        log.warn("响应状态: {}", response.getStatus());
+        log.warn("响应内容: {}", r);
         log.info("耗时 {} ms", stopWatch.getTotalTimeMillis());
         STOP_WATCH_THREAD_LOCAL.remove();
         return false;
     }
 
     private boolean unauthorized(HttpServletResponse response) throws IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        String r = new Gson().toJson(R.error(401, "请刷新页面或重新登录"));
+        response.setCharacterEncoding(StandardCharsets.UTF_8.name());
+        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
+        String r = objectMapper.writeValueAsString(R.error(401, "请刷新页面或重新登录"));
         byte[] bytes = r.getBytes();
         response.getOutputStream().write(bytes);
         StopWatch stopWatch = STOP_WATCH_THREAD_LOCAL.get();
         stopWatch.stop();
-        log.info("返回 {}: {}", response.getStatus(), r);
+        log.warn("响应状态: {}", response.getStatus());
+        log.warn("响应内容: {}", r);
         log.info("耗时 {} ms", stopWatch.getTotalTimeMillis());
         STOP_WATCH_THREAD_LOCAL.remove();
         return false;
     }
+
+    @Override
+    public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
+        return true;
+    }
+
+    @Override
+    public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) throws IOException {
+        return inputMessage;
+    }
+
+    @Override
+    public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
+        try {
+            if (STOP_WATCH_THREAD_LOCAL.get() != null) {
+                String bodyStr = objectMapper.writeValueAsString(body);
+                log.info("请求体参数: {}", bodyStr);
+                RequestLogPo requestLogPo = REQUEST_LOG_PO_THREAD_LOCAL.get();
+                if (requestLogPo != null) {
+                    Map<String, String> requestParameters = objectMapper.readValue(requestLogPo.getRequestParameters(),
+                            TypeFactory.defaultInstance().constructMapType(Map.class, String.class, String.class));
+                    requestParameters.put("request_body", bodyStr);
+                    requestLogPo.setRequestParameters(objectMapper.writeValueAsString(requestParameters));
+                }
+            }
+        } catch (Exception e) {
+            log.error(e.toString(), e);
+        }
+        return body;
+    }
+
+    @Override
+    public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
+        return body;
+    }
+
+    @Override
+    public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
+        return true;
+    }
+
+    @Override
+    public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
+        try {
+            if (STOP_WATCH_THREAD_LOCAL.get() != null) {
+                log.info("响应内容: {}", org.apache.commons.lang3.StringUtils.substring(objectMapper.writeValueAsString(body), 0, 500));
+            }
+        } catch (Exception e) {
+            log.error(e.toString(), e);
+        }
+        return body;
+    }
 }

+ 6 - 3
src/main/java/com/example/utils/AESUtil.java

@@ -1,7 +1,7 @@
 package com.example.utils;
 
 import cn.hutool.core.codec.Base64;
-import com.google.gson.Gson;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
@@ -82,9 +82,10 @@ public class AESUtil {
         //请求的地址
         map.put("REQUEST_URL","");
         map.put("EXPIRE_TIME","604800");
+        ObjectMapper objectMapper = new ObjectMapper();
         // 加密串
         try {
-            return AESUtil.encrypt(new Gson().toJson(map), KEY);
+            return AESUtil.encrypt(objectMapper.writeValueAsString(map), KEY);
         } catch (Exception e) {
             return "";
         }
@@ -104,12 +105,14 @@ public class AESUtil {
         //请求的地址
         map.put("REQUEST_URL","");
         map.put("EXPIRE_TIME","36000");
+        ObjectMapper objectMapper = new ObjectMapper();
         // 加密串
-        String encrypt = AESUtil.encrypt(new Gson().toJson(map), "2na$$PdV9AW8b#CS");
+        String encrypt = AESUtil.encrypt(objectMapper.writeValueAsString(map), "2na$$PdV9AW8b#CS");
         // 返回
         System.out.println(encrypt);
         //解密
         System.out.println(AESUtil.decrypt(encrypt,"2na$$PdV9AW8b#CS"));
         System.out.println(AESUtil.decrypt("zoQtYlmhk/add/mBUBZD5mFJB1IXEwaLRS97Uf9z9Hlqdh8eF/add/c2gDUmD3pwGPfA8FQKBNTCB8LPlCPF/vHcU/2tL7Ps/add/6rn6w5rDS98R4GJueGgU01n12YZVS/FNx6pSI/add/BuEy1XyrSg8QBfx7igSozPxmdZ6a235/add/fqZPPSjoQReI","2na$$PdV9AW8b#CS"));
+        System.out.println(getTestToken());
     }
 }

+ 2 - 2
src/main/resources/logback-spring.xml

@@ -12,7 +12,7 @@
         <file>${PATH}/trace.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <!-- rollover daily -->
-            <fileNamePattern>${PATH}/trace.%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
+            <fileNamePattern>${PATH}/trace.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
             <!-- each file should be at most 100MB, keep 180 days worth of history, but at most 20GB -->
             <maxFileSize>100MB</maxFileSize>
             <maxHistory>180</maxHistory>
@@ -27,7 +27,7 @@
         <file>${PATH}/error.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <!-- rollover daily -->
-            <fileNamePattern>${PATH}/error.%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
+            <fileNamePattern>${PATH}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
             <!-- each file should be at most 100MB, keep 180 days worth of history, but at most 20GB -->
             <maxFileSize>100MB</maxFileSize>
             <maxHistory>180</maxHistory>

+ 0 - 62
src/test/java/com/example/GdcFinanceApiApplicationTests.java

@@ -1,73 +1,11 @@
 package com.example;
 
-import com.example.dao.common.RequestLogDao;
-import com.example.pojo.po.common.RequestLogPo;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.io.IOUtils;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Picture;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.List;
-import java.util.Map;
-
 @Slf4j
 @SpringBootTest
 @ActiveProfiles("dev")
 class GdcFinanceApiApplicationTests {
-
-    @Autowired
-    RequestLogDao requestLogDao;
-
-    @Test
-    void contextLoads() {
-        Gson gson = new Gson();
-        List<RequestLogPo> list = requestLogDao.selectList(null);
-        for (RequestLogPo requestLogPo : list) {
-            Map<String, String> map = gson.fromJson(requestLogPo.getRequestParameters(), new TypeToken<>() {});
-            System.out.println(map);
-        }
-    }
-
-    public static void main(String[] args) {
-        try(FileInputStream fis = new FileInputStream("input.xlsx");
-            Workbook workbook = new XSSFWorkbook(fis);
-            FileOutputStream fos = new FileOutputStream("output.xlsx");
-            ) {
-            // 读取水印图片
-            byte[] watermarkBytes = IOUtils.toByteArray(new FileInputStream("watermark.png"));
-            int pictureIndex = workbook.addPicture(watermarkBytes, Workbook.PICTURE_TYPE_PNG);
-
-            // 获取第一个工作表
-            Sheet sheet = workbook.getSheetAt(0);
-
-            // 设置水印图片的位置和大小
-            ClientAnchor anchor = new XSSFClientAnchor();
-            anchor.setCol1(0);
-            anchor.setRow1(0);
-            anchor.setCol2(sheet.getColumnWidth(0));
-            anchor.setRow2((int) sheet.getRow(0).getHeightInPoints());
-
-            // 添加水印图片到工作表
-            Drawing drawing = sheet.createDrawingPatriarch();
-            Picture picture = drawing.createPicture(anchor, pictureIndex);
-            picture.resize();
-            // 保存带有水印的Excel文件
-            workbook.write(fos);
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-        }
-    }
 }