Skip to content

Conversation

@zzsnowy
Copy link

@zzsnowy zzsnowy commented Sep 18, 2022

chore: resolved merge conflict

chore: resolved merge conflict
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看看哪里用到了

.throwsIf(!method1.isAnnotationPresent(SHttpSubPath.class));

SzyExceptionEnum.HTTP_CENTER_HTTPMETHOD_NOT_FOUND
.throwsIf(!method1.isAnnotationPresent(SHttpMethod.class));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考processor接口,参数校验全写在preCheck里


String url = method1.getAnnotation(SHttpSubPath.class).value();

Annotation[][] parameterAnnotations = method1.getParameterAnnotations();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 查点所有元信息
  2. 处理元信息
  3. 执行

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 加上注释

}
if(requestParammap.size() > 0){
url = url + "?";
for(Map.Entry<String, Object> entry : requestParammap.entrySet()){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 硬编码改成变量,提前一点
  2. 尝试join替代循环,如果原生join不好用,可以自己写一个JoinUtils

if(parameterAnnotations[i][0].annotationType() == SHttpBody.class){
bodyIndex = i;
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一个循环分拣出所有参数
判断分拣出来的是否为空

log.info("request:" + request);
RequestCallback requestCallback = restTemplate.httpEntityCallback(request, type);
ResponseExtractor<ResponseEntity<R>> responseExtractor = restTemplate.responseEntityExtractor(type);
return (R) ((ResponseEntity<?>)restTemplate.execute(url, httpMethod, requestCallback, responseExtractor)).getBody();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果返回值为void,请求体为空,param为空,pathVar为空,这些情况排列组合考虑一下

/**
* @author zzsnowy
*/
@Component
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要这个注解,这个类没有被注入

@@ -0,0 +1,109 @@
package com.szy.core.httpcenter;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类去实现通用的模版方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants