|
@@ -34,12 +34,14 @@ public class TokenService {
|
|
|
|
|
|
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
|
|
|
|
|
+ private final static String LOGIN_OPENID = "login_openid:";
|
|
|
+
|
|
|
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
|
|
|
|
|
/**
|
|
|
* 创建令牌
|
|
|
*/
|
|
|
- public Map<String, Object> createToken(LoginUser loginUser) {
|
|
|
+ public Map<String, Object> createToken(LoginUser loginUser,String openId) {
|
|
|
String token = UUIDUtils.uuid();
|
|
|
Long userId = loginUser.getSysUser().getUserId();
|
|
|
String userName = loginUser.getSysUser().getUserName();
|
|
@@ -59,9 +61,16 @@ public class TokenService {
|
|
|
|
|
|
// 接口返回信息
|
|
|
Map<String, Object> rspMap = new HashMap<String, Object>();
|
|
|
- rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
|
|
+ String accessToken = JwtUtils.createToken(claimsMap);
|
|
|
+ rspMap.put("access_token", accessToken);
|
|
|
rspMap.put("expires_in", expireTime);
|
|
|
rspMap.put("tenantId", tenantId);
|
|
|
+
|
|
|
+ if((openId != null) && (StringUtils.isNotBlank(openId))){
|
|
|
+ String userKey = LOGIN_OPENID+openId;
|
|
|
+ redisService.set(userKey, accessToken, expireTime, TimeUnit.MINUTES);
|
|
|
+ }
|
|
|
+
|
|
|
return rspMap;
|
|
|
}
|
|
|
|