Commit 9c6b7dc5 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 35382a4a 58bb2054
...@@ -8,16 +8,16 @@ package com.xxfc.platform.summit.model; ...@@ -8,16 +8,16 @@ package com.xxfc.platform.summit.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map; import java.util.Map;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/** /**
* 封装 access_token * 封装 access_token
*/ */
@Data
public class AccessToken implements Serializable { public class AccessToken implements Serializable {
private static final long serialVersionUID = -822464425433824314L; private static final long serialVersionUID = -822464425433824314L;
...@@ -41,8 +41,11 @@ public class AccessToken implements Serializable { ...@@ -41,8 +41,11 @@ public class AccessToken implements Serializable {
expires_in = temp.getInteger("expires_in"); expires_in = temp.getInteger("expires_in");
if (expires_in != null) if (expires_in != null){
expiredTime = System.currentTimeMillis() + ((expires_in -5) * 1000); expiredTime = System.currentTimeMillis() + ((expires_in -5) * 1000);
System.out.println("----expiredTime==="+expiredTime);
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -69,17 +72,6 @@ public class AccessToken implements Serializable { ...@@ -69,17 +72,6 @@ public class AccessToken implements Serializable {
return access_token != null; return access_token != null;
} }
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public void setExpires_in(Integer expires_in) {
this.expires_in = expires_in;
}
public void setExpiredTime(Long expiredTime) {
this.expiredTime = expiredTime;
}
public void setJson(String json) { public void setJson(String json) {
this.json = json; this.json = json;
...@@ -90,13 +82,6 @@ public class AccessToken implements Serializable { ...@@ -90,13 +82,6 @@ public class AccessToken implements Serializable {
return number == null ? null : number.intValue(); return number == null ? null : number.intValue();
} }
public String getAccessToken() {
return access_token;
}
public Integer getExpiresIn() {
return expires_in;
}
} }
...@@ -2,11 +2,7 @@ package com.xxfc.platform.summit.service; ...@@ -2,11 +2,7 @@ package com.xxfc.platform.summit.service;
import com.xxfc.platform.summit.model.AccessToken; import com.xxfc.platform.summit.model.AccessToken;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.xxfc.platform.summit.util.HttpRequestUtil; import com.xxfc.platform.summit.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -83,7 +79,7 @@ public class AccessTokenService { ...@@ -83,7 +79,7 @@ public class AccessTokenService {
* @return String accessToken * @return String accessToken
*/ */
public String getAccessTokenStr() { public String getAccessTokenStr() {
return getAccessToken().getAccessToken(); return getAccessToken().getAccess_token();
} }
/** /**
...@@ -96,17 +92,16 @@ public class AccessTokenService { ...@@ -96,17 +92,16 @@ public class AccessTokenService {
String json = HttpRequestUtil.httpGet(url+"&appid="+wy_appid+"&secret="+wy_secret); String json = HttpRequestUtil.httpGet(url+"&appid="+wy_appid+"&secret="+wy_secret);
log.info("---json===="+json); log.info("---json===="+json);
result = new AccessToken(json); result = new AccessToken(json);
log.info("---result===="+result.toString());
if (result.isAvailable()) if (result.isAvailable())
break; break;
} }
// 三次请求如果仍然返回了不可用的 access token 仍然 put 进去,便于上层通过 AccessToken 中的属性判断底层的情况 // 三次请求如果仍然返回了不可用的 access token 仍然 put 进去,便于上层通过 AccessToken 中的属性判断底层的情况
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put(wy_appid, result); obj.put(wy_appid, result);
Boolean suc=summbitRedisTemplate.opsForValue().setIfAbsent(wy_appid, obj.toJSONString()); Boolean suc=summbitRedisTemplate.opsForValue().setIfAbsent(wy_appid, obj.toJSONString());
if (suc) { if (suc) {
summbitRedisTemplate.expire(wy_appid, result.getExpiresIn(), TimeUnit.MINUTES); summbitRedisTemplate.expire(wy_appid, result.getExpires_in(), TimeUnit.MINUTES);
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment