|
1 | 1 | package me.chanjar.weixin.mp.util.http; |
2 | 2 |
|
3 | | -import me.chanjar.weixin.common.util.http.RequestExecutor; |
4 | | -import me.chanjar.weixin.common.util.http.RequestHttp; |
5 | | -import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; |
6 | | -import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor; |
7 | | -import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor; |
8 | | -import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor; |
| 3 | + |
| 4 | + import me.chanjar.weixin.common.util.http.RequestExecutor; |
| 5 | + import me.chanjar.weixin.common.util.http.RequestHttp; |
| 6 | + |
| 7 | + import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; |
| 8 | + import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor; |
| 9 | + import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor; |
| 10 | + import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor; |
| 11 | + |
9 | 12 |
|
10 | 13 | public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestExecutor<WxMpMaterialVideoInfoResult, String> { |
11 | 14 | protected RequestHttp<H, P> requestHttp; |
12 | 15 |
|
13 | 16 | public MaterialVideoInfoRequestExecutor(RequestHttp requestHttp) { |
14 | | - this.requestHttp = requestHttp; |
15 | | - } |
16 | | - |
17 | | - @Override |
18 | | - public WxMpMaterialVideoInfoResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String materialId) throws WxErrorException, IOException { |
19 | | - HttpRequest request = HttpRequest.post(uri); |
20 | | - if (proxyInfo != null) { |
21 | | - provider.useProxy(proxyInfo); |
22 | | - } |
23 | | - } |
24 | | - |
25 | | -} |
| 17 | + this.requestHttp = requestHttp; |
| 18 | + } |
| 19 | + |
| 20 | + public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) { |
| 21 | + switch (requestHttp.getRequestType()) { |
| 22 | + case apacheHttp: |
| 23 | + return new ApacheMaterialVideoInfoRequestExecutor(requestHttp); |
| 24 | + case joddHttp: |
| 25 | + return new JoddMaterialVideoInfoRequestExecutor(requestHttp); |
| 26 | + case okHttp: |
| 27 | + return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp); |
| 28 | + default: |
| 29 | + return null; |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + } |
0 commit comments