JwtUtils类
//7天过期
private static long expire = 604800;
//32位秘钥
private static String secret = "abcdfghiabcdfghiabcdfghiabcdfghi";
//生成token
public static String generateToken(String username){
Date now = new Date();
Date expiration = new Date(now.getTime() + 1000 * expire);
return Jwts.builder()
.setHeaderParam("type", "JWT")
.setSubject(username)
.setIssuedAt(now)
.setExpiration(expiration)
.signWith(SignatureAlgorithm.HS512,secret).
.compact();
}
@RequestBody注解标注的对象必须是json格式
Result类
企业中自定义的返回类,方便对情况进行解析