SnsAccessTokenBean.java
2.36 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.server.utils.weixin.bean;
import com.alibaba.fastjson.JSON;
import com.server.utils.weixin.ReturnCode;
import java.util.Map;
/**
* Created by dell on 2018/2/28.
*/
public class SnsAccessTokenBean {
private String access_token;
private Integer expires_in;
private String refresh_token;
private String openid;
private String scope;
private String unionid;
private Integer errcode;
private String errmsg;
private Long expiredTime;
private String json;
public SnsAccessTokenBean(String jsonStr) {
this.json = jsonStr;
try {
Map e = (Map) JSON.parseObject(jsonStr, Map.class);
this.access_token = (String)e.get("access_token");
this.expires_in = this.getInt(e, "expires_in");
this.refresh_token = (String)e.get("refresh_token");
this.openid = (String)e.get("openid");
this.unionid = (String)e.get("unionid");
this.scope = (String)e.get("scope");
this.errcode = this.getInt(e, "errcode");
this.errmsg = (String)e.get("errmsg");
if(this.expires_in != null) {
this.expiredTime = Long.valueOf(System.currentTimeMillis() + (long)((this.expires_in.intValue() - 5) * 1000));
}
} catch (Exception var3) {
throw new RuntimeException(var3);
}
}
public String getJson() {
return this.json;
}
private Integer getInt(Map<String, Object> temp, String key) {
Number number = (Number)temp.get(key);
return number == null?null:Integer.valueOf(number.intValue());
}
public String getAccessToken() {
return this.access_token;
}
public Integer getExpiresIn() {
return this.expires_in;
}
public String getRefresh_token() {
return this.refresh_token;
}
public String getOpenid() {
return this.openid;
}
public String getScope() {
return this.scope;
}
public Integer getErrorCode() {
return this.errcode;
}
public String getErrorMsg() {
if(this.errcode != null) {
String result = ReturnCode.get(this.errcode.intValue());
if(result != null) {
return result;
}
}
return this.errmsg;
}
public String getUnionid() {
return this.unionid;
}
}