feat: 升级版本,使用封装方法实现,支持spring5全版本

This commit is contained in:
wangyu 2023-08-09 15:10:22 +08:00
parent b79661109b
commit 598395c81f

View File

@ -5,9 +5,8 @@ import group.flyfish.rest.enums.HttpMethod;
import group.flyfish.rest.registry.proxy.RestProxyInvoker; import group.flyfish.rest.registry.proxy.RestProxyInvoker;
import group.flyfish.rest.utils.DataUtils; import group.flyfish.rest.utils.DataUtils;
import lombok.Getter; import lombok.Getter;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.MergedAnnotations;
import java.beans.Transient; import java.beans.Transient;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -77,13 +76,12 @@ public class RestMethod {
* 初始化方法 * 初始化方法
*/ */
private void init(Method method, RestProxyInvoker invoker) { private void init(Method method, RestProxyInvoker invoker) {
MergedAnnotation<RestApi> annotation = MergedAnnotations.from(method).get(RestApi.class); RestApi restApi = AnnotatedElementUtils.findMergedAnnotation(method, RestApi.class);
// 无视proxy因为啥也没 // 无视proxy因为啥也没
if (!annotation.isPresent()) { if (null == restApi) {
this.invalid = true; this.invalid = true;
return; return;
} }
RestApi restApi = annotation.synthesize();
this.url = determineUrl(restApi, invoker); this.url = determineUrl(restApi, invoker);
this.method = restApi.method(); this.method = restApi.method();
this.credentials = restApi.credentials(); this.credentials = restApi.credentials();