package cn.exploring.engine.server.wx.dao;

import com.alibaba.fastjson.JSON;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

public class UserToken {
    private Integer userId;
    private String token;
    private String sessionKey;
    private Long updateTime;

    @Override
    public String toString() {
        updateTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        return JSON.toJSONString(this);
    }

    public static UserToken toObj(Object json) {
        UserToken obj = null;
        try {
            obj = JSON.parseObject(json.toString(), UserToken.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return obj;
    }

    public String getSessionKey() {
        return sessionKey;
    }

    public void setSessionKey(String sessionKey) {
        this.sessionKey = sessionKey;
    }

    public Integer getUserId() {
        return userId;
    }

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

    public String getToken() {
        return token;
    }

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

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }
}
