diff --git a/service/src/main/java/cn/bunny/services/aop/UserRequestLogAop.java b/service/src/main/java/cn/bunny/services/aop/UserRequestLogAop.java index b2787e9..012df32 100644 --- a/service/src/main/java/cn/bunny/services/aop/UserRequestLogAop.java +++ b/service/src/main/java/cn/bunny/services/aop/UserRequestLogAop.java @@ -17,6 +17,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -30,6 +32,18 @@ public class UserRequestLogAop { @Autowired private UserRequestLogRepository userRequestLogRepository; + private boolean isSerializable(Object obj) { + try { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(bytes); + out.writeObject(obj); + out.close(); + return true; + } catch (Exception e) { + return false; + } + } + @Around(value = "execution(* cn.bunny.services.controller.*.*.*(..)) && !@annotation(cn.bunny.services.aop.annotation.ExcludeRequestLog)") public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable { LoginVo loginVo = BaseContext.getLoginVo(); @@ -52,8 +66,9 @@ public class UserRequestLogAop { userRequestLog.setIpRegion(ipRegion); userRequestLog.setExecuteTime(executeTime); - - userRequestLog.setArg(JSON.toJSONString(args)); + // 判断传入参数能否被序列化 + Object saveArgs = isSerializable(args) ? JSON.toJSONString(args) : ""; + userRequestLog.setArg(JSON.toJSONString(saveArgs)); // 当前请求request ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java index aeda011..fc66e67 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/BillServiceImpl.java @@ -41,6 +41,7 @@ import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; @@ -60,6 +61,7 @@ import java.util.stream.Collectors; * @since 2024-11-07 16:49:19 */ @Service +@Transactional public class BillServiceImpl extends ServiceImpl implements BillService { @Autowired diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml index 88951bd..6697786 100644 --- a/service/src/main/resources/application-dev.yml +++ b/service/src/main/resources/application-dev.yml @@ -1,3 +1,5 @@ +server: + port: 1010 logging: level: cn.bunny.service.mapper: info @@ -43,5 +45,4 @@ bunny: secretKey: "02120212" bucket-name: financial - backPath: "D:\\MyData\\backup" - bashPath: "D:\\MyData" + bashPath: "D:\\MyData" \ No newline at end of file diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml index 66625b2..e792e65 100644 --- a/service/src/main/resources/application.yml +++ b/service/src/main/resources/application.yml @@ -1,6 +1,3 @@ -server: - port: 1000 - spring: profiles: active: @profiles.active@