You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
	
	
		
		
			
	
	
		
			
				
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								package com.epmet.redis;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import cn.hutool.core.bean.BeanUtil;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import com.epmet.commons.tools.redis.RedisKeys;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import com.epmet.commons.tools.redis.RedisUtils;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import com.epmet.commons.tools.security.dto.TokenDto;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import org.springframework.beans.factory.annotation.Autowired;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import org.springframework.stereotype.Component;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								import java.util.Map;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								 * @Author zxc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								 * @DateTime 2021/1/18 下午5:09
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								@Component
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								public class SsoRedis {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								    @Autowired
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								    private RedisUtils redisUtils;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								    /**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     * @Description  token放入缓存
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     * @Param user
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     * @Param expire
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     * @author zxc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     * @date 2021/1/18 下午5:10
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								     */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								    public void set(TokenDto user, long expire) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								        if (user == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								            return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
								        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);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
								}
							 |