All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lx.entity.JwtInfo Maven / Gradle / Ivy

Go to download

使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink

There is a newer version: 1.1
Show newest version
package com.lx.entity;

import com.lx.annotation.Note;

import java.io.Serializable;
import java.util.concurrent.TimeUnit;

public class JwtInfo implements Serializable {
    private UserInfo userInfo;
    private long exp;

    public JwtInfo() {

    }
    public JwtInfo(UserInfo userInfo, TimeUnit timeUnit, long time) {
        this.userInfo = userInfo;
        this.exp = calcExp(timeUnit,time);
    }

    public UserInfo getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        this.userInfo = userInfo;
    }

    public long getExp() {
        return exp;
    }

    public void setExp(long exp) {
        this.exp = exp;
    }

    @Note("计算超时时间")
    public long calcExp(TimeUnit timeUnit, long time){
        return System.currentTimeMillis()+timeUnit.toMillis(time);
    }

    @Note("token是否过期")
    public boolean expired(){
        return System.currentTimeMillis() > exp;
    }

    @Override
    public String toString() {
        return "JwtInfo{" +
                "userInfo=" + userInfo +
                ", exp=" + exp +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy