-
Notifications
You must be signed in to change notification settings - Fork 0
feat: http请求框架 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
chore: resolved merge conflict
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-web</artifactId> | ||
| </dependency> |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 查点所有元信息
- 处理元信息
- 执行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 加上注释
| } | ||
| if(requestParammap.size() > 0){ | ||
| url = url + "?"; | ||
| for(Map.Entry<String, Object> entry : requestParammap.entrySet()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 硬编码改成变量,提前一点
- 尝试join替代循环,如果原生join不好用,可以自己写一个JoinUtils
| if(parameterAnnotations[i][0].annotationType() == SHttpBody.class){ | ||
| bodyIndex = i; | ||
| } | ||
| } |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个类去实现通用的模版方法
chore: resolved merge conflict