package com.supplier.util;

import com.auth0.jwt.JWT;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 解析token
 */
public class ParsingToken {
    public static Map<String, Object> tokenParsing(HttpServletRequest request){
        Map<String, Object> map = new HashMap<>();
        //解密token
        String tokenDec = DesDecry.decrypt(request.getHeader("token"));
        String code = JWT.decode(tokenDec).getClaim("code").asString();//用户编号
        String phone = JWT.decode(tokenDec).getClaim("phone").asString();//手机号
        map.put("code", code);
        map.put("phone", phone);
        System.out.println(code);
        return map;
    }
}
