|
|
@ -30,11 +30,11 @@ public class CpUserDetailRedis { |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
public void set(String tokenStr,TokenDto user, long expire) { |
|
|
|
public void set(TokenDto user, long expire) { |
|
|
|
if (user == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String key = RedisKeys.getCpUserKey(tokenStr); |
|
|
|
String key = RedisKeys.getCpUserKey(user.getApp(), user.getClient(), user.getUserId()); |
|
|
|
//bean to map
|
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(user, false, true); |
|
|
|
redisUtils.hMSet(key, map, expire); |
|
|
@ -43,11 +43,13 @@ public class CpUserDetailRedis { |
|
|
|
/** |
|
|
|
* 获取token信息 |
|
|
|
* |
|
|
|
* @param tokenStr token字符串 |
|
|
|
* @param app 居民端resi;政府端gov;运营端oper |
|
|
|
* @param client PC端:web;微信小程序端:wxmp |
|
|
|
* @param userId oper_user、customer_user、customer_staff表主键 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public TokenDto get(String tokenStr) { |
|
|
|
String key = RedisKeys.getCpUserKey(tokenStr); |
|
|
|
public TokenDto get(String app, String client, String userId) { |
|
|
|
String key = RedisKeys.getCpUserKey(app,client,userId); |
|
|
|
|
|
|
|
Map<String, Object> map = redisUtils.hGetAll(key); |
|
|
|
if (MapUtil.isEmpty(map)) { |
|
|
@ -63,32 +65,38 @@ public class CpUserDetailRedis { |
|
|
|
/** |
|
|
|
* 删除用户信息 |
|
|
|
* |
|
|
|
* @param tokenStr token字符串 |
|
|
|
* @param app 居民端resi;政府端gov;运营端oper |
|
|
|
* @param client PC端:web;微信小程序端:wxmp |
|
|
|
* @param userId oper_user、customer_user、customer_staff表主键 |
|
|
|
*/ |
|
|
|
public void logout(String tokenStr) { |
|
|
|
redisUtils.delete(RedisKeys.getCpUserKey(tokenStr)); |
|
|
|
public void logout(String app, String client, String userId) { |
|
|
|
redisUtils.delete(RedisKeys.getCpUserKey(app,client,userId)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置redis时间 |
|
|
|
* |
|
|
|
* @param tokenStr |
|
|
|
* @param expire |
|
|
|
* @param app 居民端resi;政府端gov;运营端oper |
|
|
|
* @param client PC端:web;微信小程序端:wxmp |
|
|
|
* @param userId oper_user、customer_user、customer_staff表主键 |
|
|
|
* @param expire 有效时间 |
|
|
|
* @author rongchao |
|
|
|
*/ |
|
|
|
public boolean expire(String tokenStr, long expire) { |
|
|
|
return redisUtils.expire(RedisKeys.getCpUserKey(tokenStr), expire); |
|
|
|
public boolean expire(String app, String client, String userId, long expire) { |
|
|
|
return redisUtils.expire(RedisKeys.getCpUserKey(app,client,userId), expire); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询token剩余时间 |
|
|
|
* |
|
|
|
* @param tokenStr |
|
|
|
* @return long |
|
|
|
* @param app 居民端resi;政府端gov;运营端oper |
|
|
|
* @param client PC端:web;微信小程序端:wxmp |
|
|
|
* @param userId oper_user、customer_user、customer_staff表主键 |
|
|
|
* @return 获取有效期 |
|
|
|
* @author yujintao |
|
|
|
* @date 2019/9/9 14:18 |
|
|
|
*/ |
|
|
|
public long getExpire(String tokenStr) { |
|
|
|
return redisUtils.getExpire(RedisKeys.getCpUserKey(tokenStr)); |
|
|
|
public long getExpire(String app, String client, String userId) { |
|
|
|
return redisUtils.getExpire(RedisKeys.getCpUserKey(app, client, userId)); |
|
|
|
} |
|
|
|
} |
|
|
|