| | |
| | | package com.doumee.config.jwt; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import io.jsonwebtoken.Jwts; |
| | | import io.jsonwebtoken.SignatureAlgorithm; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private JwtProperties jwtProperties; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz ; |
| | | |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | /** |
| | | * 生成token令牌 |
| | | * |
| | |
| | | // this.hkLoginOut(url+"?token="+loginUserInfo.getHkMenuToken()); |
| | | HttpsUtil.get(url+"?token="+loginUserInfo.getHkMenuToken(),true); |
| | | } |
| | | redisTemplate.delete(Constants.REDIS_TOKEN_KEY+token);//删除老的token |
| | | |
| | | //删除老的token |
| | | redisTemplate.delete(Constants.REDIS_TOKEN_KEY+token); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void logoutForH5(String token) { |
| | | try { |
| | | //登出海康系统数据 |
| | | LoginUserInfo loginUserInfo = this.getUserInfoByToken(token); |
| | | //删除老的token |
| | | redisTemplate.delete(Constants.REDIS_TOKEN_KEY+token); |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda().set(SystemUser::getOpenid,null) |
| | | .eq(SystemUser::getId,loginUserInfo.getId())); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | public void hkLoginOut(String url){ |
| | | try { |
| | | // 创建HttpClient对象 |
| | |
| | | } |
| | | return claims; |
| | | } |
| | | |
| | | /** |
| | | * 向后延伸有效期保持会话继续 |
| | | * @param token |
| | | */ |
| | | |
| | | public void refreshTokenTime(String token,String usrerInfo) { |
| | | redisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token,usrerInfo,jwtProperties.getExpiration(), TimeUnit.MILLISECONDS); |
| | | } |
| | | } |