我已经定义了一个自定义方面,它可以查找资源进行少量验证并快速失败。如果验证成功,我如何将资源传递给我的Rest Controller类以避免额外的数据库查找
答案 0 :(得分:0)
您可以这样做:
@Aspect
@Component
public class SomeAspectClass {
@Around("execution(* com.example.controller.yourController.yourMethod (SomeClass)) && args(someObject)")
public Object sendDataToControllerMethod(ProceedingJoinPoint proceedingJoinPoint, SomeClass someObject) {
//Do your validation, db related works
// "someObject" can be filled, changed etc. here
YourMethodReturnClass yourMethodReturnObject = (YourMethodReturnClass) proceedingJoinPoint.proceed(new Object[] {someObject});
return yourMethodReturnObject;
}
}