package ink.wgink.pojo.app;

import java.io.Serializable;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: TokenInfo
 * @Description: token信息
 * @Author: WangGeng
 * @Date: 2019-08-02 11:19
 * @Version: 1.0
 **/
public class AppToken implements Serializable {

    private static final long serialVersionUID = 1338652146163739437L;
    private String token;
    private AppTokenTypeEnum appTokenTypeEnum;
    private long lastTime;
    private String userId;
    private AppTokenUser appTokenUser;

    public String getToken() {
        return token == null ? "" : token.trim();
    }

    public void setToken(String token) {
        this.token = token;
    }

    public AppTokenTypeEnum getAppTokenTypeEnum() {
        return appTokenTypeEnum;
    }

    public void setAppTokenTypeEnum(AppTokenTypeEnum appTokenTypeEnum) {
        this.appTokenTypeEnum = appTokenTypeEnum;
    }

    public long getLastTime() {
        return lastTime;
    }

    public void setLastTime(long lastTime) {
        this.lastTime = lastTime;
    }

    public String getUserId() {
        return userId == null ? "" : userId.trim();
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public AppTokenUser getAppTokenUser() {
        return appTokenUser;
    }

    public void setAppTokenUser(AppTokenUser appTokenUser) {
        this.appTokenUser = appTokenUser;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"token\":")
                .append("\"").append(token).append("\"");
        sb.append(",\"appTokenTypeEnum\":")
                .append(appTokenTypeEnum);
        sb.append(",\"lastTime\":")
                .append(lastTime);
        sb.append(",\"userId\":")
                .append("\"").append(userId).append("\"");
        sb.append(",\"appTokenUser\":")
                .append(appTokenUser);
        sb.append('}');
        return sb.toString();
    }

    public enum AppTokenTypeEnum {

        WECHAT("wechat"),
        WECHAT_MINI_APP("wxminiapp"),
        APP("app");
        private String type;

        AppTokenTypeEnum(String type) {
            this.type = type;
        }

        public String getType() {
            return type == null ? "" : type.trim();
        }
    }
}
