package com.tiesheng.core.config.token.bean;

import cn.hutool.jwt.JWT;

public class TokenBean {

    private String id;
    private String environmentType;
    private String service;
    private String extra;

    public TokenBean() {
    }

    public TokenBean(String id, String environmentType, String service) {
        this.id = id;
        this.environmentType = environmentType;
        this.service = service;
        this.extra = "";
    }

    /**
     * 设置token
     */
    public String toToken() {
        byte[] key = "%kIp9frQCu".getBytes();
        return JWT.create()
                .setPayload("id", id)
                .setPayload("environmentType", environmentType)
                .setPayload("service", service)
                .setPayload("extra", extra)
                .setPayload("time", System.currentTimeMillis())
                .setKey(key)
                .sign();
    }

    ///////////////////////////////////////////////////////////////////////////
    // setter\getter
    ///////////////////////////////////////////////////////////////////////////

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getEnvironmentType() {
        return environmentType;
    }

    public void setEnvironmentType(String environmentType) {
        this.environmentType = environmentType;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }
}
