@@ -26,4 +26,10 @@ public interface TokenService {
*/
Boolean verifyToken(String token, Integer type);
+ /**
+ * 删除用户token
+ * @param userId 用户ID
+ * @return 删除是否成功
+ */
+ Boolean deleteToken(String userId);
}
@@ -125,4 +125,21 @@ public class TokenServiceImpl implements TokenService {
return res;
+
+ @Override
+ public Boolean deleteToken(String userId){
+ final byte[] redis_key = getUserTokenKey(userId);
+ Long l = (Long) redisForToken.execute(new RedisCallback<Long>() {
+ public Long doInRedis(RedisConnection connection) throws DataAccessException {
+ return connection.del(redis_key);
+ }
+ });
+ return l > 0;