package com.xhpc.evcs.domain;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@Entity
@Table(name = "ET_AUTH_SEC_TOKEN")
public class AuthSecretToken {

    public final static String SECRET_TOKEN_TYPE_IN = "IN";
    public final static String SECRET_TOKEN_TYPE_OUT = "OUT";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    private String operatorId;

    private String operatorId3irdpty;

    private String urlPrefix;

    private String secretTokenType;

    private String operatorSecret;

    private String sigSecret;

    private String dataSecret;

    private String dataSecretIV;

    private String token;

    private Date tokenExpiry;

    private boolean encrypt;

    private Long lastPushOrder;

    private Integer status;

    public AuthSecretToken() {

    }

    public AuthSecretToken(String operatorId, String secretTokenType) {

        this.operatorId = operatorId;
        this.secretTokenType = secretTokenType;
    }

    public Long getLastPushOrder() {

        return lastPushOrder == null ? 0 : lastPushOrder;
    }

    public void setLastPushOrder(Long lastPushOrder) {

        this.lastPushOrder = lastPushOrder;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "AuthSecretToken{" +
                "id=" + id +
                ", operatorId='" + operatorId + '\'' +
                ", operatorId3irdpty='" + operatorId3irdpty + '\'' +
                ", urlPrefix='" + urlPrefix + '\'' +
                ", secretTokenType='" + secretTokenType + '\'' +
                ", operatorSecret='" + operatorSecret + '\'' +
                ", sigSecret='" + sigSecret + '\'' +
                ", dataSecret='" + dataSecret + '\'' +
                ", dataSecretIV='" + dataSecretIV + '\'' +
                ", token='" + token + '\'' +
                ", tokenExpiry=" + tokenExpiry +
                ", encrypt=" + encrypt +
                ", lastPushOrder=" + lastPushOrder +
                ", status=" + status +
                '}';
    }
}
