|
|
@@ -385,7 +385,7 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
REnterpriseVo enterprise = systemService.queryEntDetails(driver.getEntId());
|
|
|
|
|
|
/**生成token**/
|
|
|
- String token = EncryUtil.encryV1(Global.PRI_KEY, String.valueOf(driver.getId()));
|
|
|
+ String token = generateToken(loginBase, driver.getId());
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
}
|
|
|
@@ -441,7 +441,7 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
}
|
|
|
|
|
|
/**生成token**/
|
|
|
- String token = EncryUtil.encryV1(Global.PRI_KEY, String.valueOf(user.getId()));
|
|
|
+ String token = generateToken(loginBase, user.getId());
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
}
|
|
|
@@ -470,6 +470,24 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
return HttpResult.ok(loginRes);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param loginBase {}
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @desc 生成token
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/8/18
|
|
|
+ **/
|
|
|
+ private String generateToken(LoginBase loginBase, Long userId) {
|
|
|
+ Map<String, Object> info = new HashMap();
|
|
|
+ info.put("userId", userId);
|
|
|
+ info.put("account", loginBase.getAccount());
|
|
|
+ info.put("clientType", loginBase.getClientType());
|
|
|
+ info.put("systemType", loginBase.getSystemType());
|
|
|
+ info.put("timestamp", System.currentTimeMillis());
|
|
|
+ String token = EncryUtil.encryV1(Global.PRI_KEY, JSON.toJSONString(info));
|
|
|
+ return token;
|
|
|
+ }
|
|
|
+
|
|
|
static class AsyncProcess1 implements Runnable {
|
|
|
private final LoginBase loginBase;
|
|
|
|
|
|
@@ -540,8 +558,10 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
loginUserInfo.setEntId(enterprise != null ? enterprise.getId() : null);
|
|
|
loginUserInfo.setEntName(enterprise != null ? enterprise.getFirmName() : null);
|
|
|
loginUserInfo.setClientType(loginBase.getClientType());
|
|
|
+ loginUserInfo.setTimestamp(System.currentTimeMillis());
|
|
|
+ int expireTime = ClientTypeEnum.expireTime(loginBase.getClientType());
|
|
|
String key = Global.getFullUserLoginKey(loginUserInfo.getSystemType(), loginUserInfo.getId(), loginBase.getClientType());
|
|
|
- RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
|
|
|
+ RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo), expireTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -566,9 +586,10 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
loginUserInfo.setIsMain(user.getIsMain());
|
|
|
loginUserInfo.setEntId(user.getEntId());
|
|
|
loginUserInfo.setEntName(enterprise != null ? enterprise.getFirmName() : null);
|
|
|
+ loginUserInfo.setTimestamp(System.currentTimeMillis());
|
|
|
+ int expireTime = ClientTypeEnum.expireTime(loginBase.getClientType());
|
|
|
String key = Global.getFullUserLoginKey(loginUserInfo.getSystemType(), loginUserInfo.getId(), loginBase.getClientType());
|
|
|
- RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo),
|
|
|
- loginBase.getClientType().equals(ClientTypeEnum.pc.getValue()) ? Global.PC_TOKEN_EXPIRE : Global.APP_TOKEN_EXPIRE);
|
|
|
+ RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo), expireTime);
|
|
|
|
|
|
//存缓存请求地址
|
|
|
SaveMenusToCache(user);
|