1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package com.ozs.common.utils;
- import com.ozs.common.core.redis.RedisCache;
- import com.ozs.common.utils.uuid.IdUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.Map;
- import java.util.concurrent.TimeUnit;
- /**
- * 车载心跳机制交互缓存工具类
- *
- * @author Administrator
- */
- @Component
- public class HeartbeatUtils {
- @Autowired
- private RedisCache redisCache;
- /**
- * 获取信息
- *
- * @return Redis存储的key
- */
- public String getHeartbeat(String code) {
- // 获取请求携带的令牌
- if (StringUtils.isNotEmpty(code)) {
- try {
- // 解析对应的权限
- return redisCache.getCacheObject(code);
- } catch (Exception e) {
- }
- }
- return null;
- }
- /**
- * 存储信息
- *
- * @return
- */
- public void createHeartbeat(String code, String site) {
- redisCache.setCacheObject(code, site, 10, TimeUnit.MINUTES);
- }
- /**
- * 删除信息
- * @param code
- * @return
- */
- public boolean deleteHeartbeat(String code) {
- return redisCache.deleteObject(code);
- }
- }
|