| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.ruoyi.system.api.model.AppMiniLoginVo; |
| | | import com.ruoyi.system.api.model.OauthUserVo; |
| | | import com.ruoyi.system.api.model.QwH5LoginVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | |
| | | |
| | | /** |
| | | * token验证处理 |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | * @author jqs |
| | | */ |
| | | @Component |
| | | public class TokenService |
| | |
| | | refreshToken(loginUser); |
| | | |
| | | // Jwt存储信息 |
| | | Map<String, Object> claimsMap = new HashMap<String, Object>(); |
| | | Map<String, Object> claimsMap = new HashMap<>(); |
| | | claimsMap.put(SecurityConstants.USER_KEY, token); |
| | | claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | |
| | | rspMap.put("expires_in", expireTime); |
| | | rspMap.put("mini_openid", appMiniLoginVo.getMiniOpenid()); |
| | | return rspMap; |
| | | } |
| | | |
| | | /** |
| | | * 创建小程序令牌 |
| | | */ |
| | | public OauthUserVo createQwH5Token(QwH5LoginVo qwH5LoginVo) |
| | | { |
| | | LoginUser loginUser = new LoginUser(); |
| | | loginUser.setSysUser(qwH5LoginVo.getSysUser()); |
| | | String token = IdUtils.fastUUID(); |
| | | Long userId = loginUser.getSysUser().getUserId(); |
| | | String userName = loginUser.getSysUser().getUserName(); |
| | | loginUser.setToken(token); |
| | | loginUser.setUserid(userId); |
| | | loginUser.setUsername(userName); |
| | | loginUser.setIpaddr(IpUtils.getIpAddr()); |
| | | refreshToken(loginUser); |
| | | |
| | | // Jwt存储信息 |
| | | Map<String, Object> claimsMap = new HashMap<String, Object>(); |
| | | claimsMap.put(SecurityConstants.USER_KEY, token); |
| | | claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | | |
| | | // 接口返回信息 |
| | | OauthUserVo oauthUserVo = new OauthUserVo(); |
| | | oauthUserVo.setShopId(qwH5LoginVo.getShopId()); |
| | | oauthUserVo.setToken(JwtUtils.createToken(claimsMap)); |
| | | oauthUserVo.setExpiresIn(expireTime); |
| | | oauthUserVo.setUserid(qwH5LoginVo.getUserid()); |
| | | oauthUserVo.setMobile(qwH5LoginVo.getMobile()); |
| | | return oauthUserVo; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return ACCESS_TOKEN + token; |
| | | } |
| | | } |
| | | } |