1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.yanzuoguang.wxxcx.user.checkencrypted;
import com.alibaba.fastjson.TypeReference;
import com.yanzuoguang.util.helper.CheckerHelper;
import com.yanzuoguang.util.helper.HttpHelper;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.wxxcx.base.*;
/**
* 检查加密信息是否由微信生成 转换
*
* @author 颜佐光
*/
public class WxXcxAuthCheckEncryptedDataRequest implements WxXcxRequestUrl, WxXcxRequestUrlPara, WxXcxRequestPostFormData {
private final WxXcxConfig wxXcxConfig;
private final WxXcxRequest wxXcxRequest;
private final WxXcxAccessToken accessToken;
private final WxXcxAuthCheckEncryptedDataReq req;
public WxXcxAuthCheckEncryptedDataRequest(WxXcxConfig wxXcxConfig, WxXcxRequest wxXcxRequest, WxXcxAccessToken accessToken, WxXcxAuthCheckEncryptedDataReq req) {
this.wxXcxConfig = wxXcxConfig;
this.wxXcxRequest = wxXcxRequest;
this.accessToken = accessToken;
this.req = req;
}
@Override
public String getUrl() {
return wxXcxConfig.getBaseUrl() + wxXcxConfig.getAuthCheckEncryptedDataUrl() + "?" + this.getUrlPara();
}
@Override
public String getUrlPara() {
return HttpHelper.getUrlParameter(accessToken);
}
@Override
public String getPost() {
return HttpHelper.getUrlParameter(req);
}
public WxXcxAuthCheckEncryptedDataRes getResponse() {
checkParam(req);
return this.wxXcxRequest.request(this, response -> {
WxXcxAuthCheckEncryptedDataRes ret = JsonHelper.deserialize(response, new TypeReference<WxXcxAuthCheckEncryptedDataRes>() {
});
WxXcxAssert.assertBaseError(ret);
return ret;
});
}
private void checkParam(WxXcxAuthCheckEncryptedDataReq req) {
CheckerHelper.newInstance()
.notBlankCheck("encrypted_msg_hash", req.getEncrypted_msg_hash())
.checkException();
}
}