|
@@ -44,18 +44,18 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
// String appInfo = redis.get(cacheKey);
|
|
|
AppToken token = null;
|
|
|
// if (StringUtils.isBlank(appInfo)) {
|
|
|
- token = selectByPrimaryKey(appId);
|
|
|
+ /* token = selectByPrimaryKey(appId);
|
|
|
if (null == token) {
|
|
|
LogUtil.error(logger, "app_token记录不存在,appId:{0}", appId);
|
|
|
throw new ServiceException();
|
|
|
}
|
|
|
- /*updateCache = true;
|
|
|
+ updateCache = true;
|
|
|
} else {
|
|
|
token = JSON.parseObject(appInfo, AppToken.class);
|
|
|
}
|
|
|
*/
|
|
|
- LogUtil.info(logger, "token: {0}", JSON.toJSONString(token));
|
|
|
- if (token.getExpireTimestamp().getTime() < System.currentTimeMillis()) {
|
|
|
+ // LogUtil.info(logger, "token: {0}", JSON.toJSONString(token));
|
|
|
+ // if (token.getExpireTimestamp().getTime() < System.currentTimeMillis()) {
|
|
|
String res = wxGetAccessToken(appId, token.getAppSecret());
|
|
|
if (StringUtils.isEmpty(res)) {
|
|
|
LogUtil.error(logger, "获取access_token为空,appId:{0}, res:{1}", appId,
|
|
@@ -64,7 +64,8 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
String accessToken = jsonObject.getString("access_token");
|
|
|
- Integer expiresIn = jsonObject.getInteger("expires_in");
|
|
|
+ return accessToken;
|
|
|
+ /*Integer expiresIn = jsonObject.getInteger("expires_in");
|
|
|
if (StringUtils.isEmpty(accessToken)) {
|
|
|
LogUtil.error(logger, "获取access_token为空,appId:{0}, res:{1}",
|
|
|
appId, res);
|
|
@@ -73,10 +74,10 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
token.setAccessToken(accessToken);
|
|
|
// 防止时间不同步,此处提前100s超时
|
|
|
token.setExpireTimestamp(DateUtils.addSeconds(new Date(), expiresIn - 100));
|
|
|
- appTokenMapper.updateByPrimaryKeySelective(token);
|
|
|
+ appTokenMapper.updateByPrimaryKeySelective(token);*/
|
|
|
// updateCache = true;
|
|
|
|
|
|
- }
|
|
|
+ // }
|
|
|
/*
|
|
|
if (updateCache) {
|
|
|
boolean result = redis.set(cacheKey, JSON.toJSONString(token));
|
|
@@ -85,7 +86,7 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
- return token.getAccessToken();
|
|
|
+ // return token.getAccessToken();
|
|
|
}
|
|
|
|
|
|
private String wxGetAccessToken(String appId, String appSecret) {
|