mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-22 15:35:03 +00:00
work with audit
This commit is contained in:
parent
96aa5c024d
commit
4f5236fa82
@ -10,6 +10,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.*;
|
import org.aspectj.lang.annotation.*;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import stirling.software.common.service.JobExecutorService;
|
|||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Order(0) // Highest precedence - executes before audit aspects
|
||||||
public class AutoJobAspect {
|
public class AutoJobAspect {
|
||||||
|
|
||||||
private static final Duration RETRY_BASE_DELAY = Duration.ofMillis(100);
|
private static final Duration RETRY_BASE_DELAY = Duration.ofMillis(100);
|
||||||
@ -40,6 +42,7 @@ public class AutoJobAspect {
|
|||||||
@Around("@annotation(autoJobPostMapping)")
|
@Around("@annotation(autoJobPostMapping)")
|
||||||
public Object wrapWithJobExecution(
|
public Object wrapWithJobExecution(
|
||||||
ProceedingJoinPoint joinPoint, AutoJobPostMapping autoJobPostMapping) {
|
ProceedingJoinPoint joinPoint, AutoJobPostMapping autoJobPostMapping) {
|
||||||
|
// This aspect will run before any audit aspects due to @Order(0)
|
||||||
// Extract parameters from the request and annotation
|
// Extract parameters from the request and annotation
|
||||||
boolean async = Boolean.parseBoolean(request.getParameter("async"));
|
boolean async = Boolean.parseBoolean(request.getParameter("async"));
|
||||||
long timeout = autoJobPostMapping.timeout();
|
long timeout = autoJobPostMapping.timeout();
|
||||||
|
@ -26,6 +26,7 @@ import stirling.software.proprietary.service.AuditService;
|
|||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@org.springframework.core.annotation.Order(10) // Lower precedence (higher number) - executes after AutoJobAspect
|
||||||
public class AuditAspect {
|
public class AuditAspect {
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
|
@ -36,6 +36,7 @@ import stirling.software.proprietary.service.AuditService;
|
|||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@org.springframework.core.annotation.Order(10) // Lower precedence (higher number) - executes after AutoJobAspect
|
||||||
public class ControllerAuditAspect {
|
public class ControllerAuditAspect {
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
@ -77,6 +78,12 @@ public class ControllerAuditAspect {
|
|||||||
return auditController(joinPoint, "PATCH");
|
return auditController(joinPoint, "PATCH");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Intercept all methods with AutoJobPostMapping annotation */
|
||||||
|
@Around("@annotation(stirling.software.common.annotations.AutoJobPostMapping)")
|
||||||
|
public Object auditAutoJobMethod(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
return auditController(joinPoint, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
private Object auditController(ProceedingJoinPoint joinPoint, String httpMethod)
|
private Object auditController(ProceedingJoinPoint joinPoint, String httpMethod)
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
MethodSignature sig = (MethodSignature) joinPoint.getSignature();
|
MethodSignature sig = (MethodSignature) joinPoint.getSignature();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user