| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.home.aspectj; |
| | | |
| | | import com.ruoyi.home.annotation.DefaultType; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Parameter; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç»è®¡ç±»åé»è®¤å¼æ³¨è§£åé¢ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/2/5 |
| | | */ |
| | | |
| | | @Aspect |
| | | @Component |
| | | public class DefaultTypeAspect { |
| | | |
| | | @Around("execution(* com.ruoyi.home.controller.*.*(.., @com.ruoyi.home.annotation.DefaultType (*), ..))") |
| | | public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | Object[] args = joinPoint.getArgs(); |
| | | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
| | | Parameter[] parameters = signature.getMethod().getParameters(); |
| | | |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | DefaultType annotation = parameters[i].getAnnotation(DefaultType.class); |
| | | if (annotation != null && args[i] == null) { |
| | | args[i] = Integer.parseInt(annotation.value()); |
| | | } |
| | | } |
| | | return joinPoint.proceed(args); |
| | | } |
| | | } |