|
@@ -37,23 +37,23 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
|
|
|
@Override
|
|
|
public String getAccessToken(String appId) {
|
|
|
- String cacheKey = RedisKey.build(RedisKey.WX_APP_TOKEN_KEY, appId);
|
|
|
+// String cacheKey = RedisKey.build(RedisKey.WX_APP_TOKEN_KEY, appId);
|
|
|
|
|
|
- boolean updateCache = false;
|
|
|
+// boolean updateCache = false;
|
|
|
|
|
|
- String appInfo = redis.get(cacheKey);
|
|
|
+// String appInfo = redis.get(cacheKey);
|
|
|
AppToken token = null;
|
|
|
- if (StringUtils.isBlank(appInfo)) {
|
|
|
+// if (StringUtils.isBlank(appInfo)) {
|
|
|
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()) {
|
|
|
String res = wxGetAccessToken(appId, token.getAppSecret());
|
|
@@ -74,16 +74,16 @@ public class AppTokenServiceImpl implements IAppTokenService {
|
|
|
// 防止时间不同步,此处提前100s超时
|
|
|
token.setExpireTimestamp(DateUtils.addSeconds(new Date(), expiresIn - 100));
|
|
|
appTokenMapper.updateByPrimaryKeySelective(token);
|
|
|
- updateCache = true;
|
|
|
+ // updateCache = true;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+/*
|
|
|
if (updateCache) {
|
|
|
boolean result = redis.set(cacheKey, JSON.toJSONString(token));
|
|
|
if (!result) {
|
|
|
LogUtil.error(logger, "appsecret key set error.cacheKey:", cacheKey);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
return token.getAccessToken();
|
|
|
}
|