package com.market.model;

import com.market.utils.SpotConstant;

/**
 * MQ/Kafka 行情消息
 *
 * @author system
 * @date 2026-05-07
 */
public class SpotMqMessage {

    /** 币对，如 BTCUSDT */
    private String symbol;

    /**
     * 数据类型：trade / kline_1m / depth / ticker
     */
    private String data_type;

    /** 消息内容 */
    private Object message;

    /** 时间戳（13位毫秒） */
    private Long timestamp;

    /**
     * 检查消息是否过期（超过 60 秒视为过期）
     *
     * @return true=已过期
     */
    public boolean isExpired() {
        if (timestamp == null) {
            return false;
        }
        return System.currentTimeMillis() - timestamp > SpotConstant.MESSAGE_EXPIRE_TIME_MS;
    }

    public String getSymbol() { return symbol; }
    public void setSymbol(String symbol) { this.symbol = symbol; }
    public String getData_type() { return data_type; }
    public void setData_type(String data_type) { this.data_type = data_type; }
    public Object getMessage() { return message; }
    public void setMessage(Object message) { this.message = message; }
    public Long getTimestamp() { return timestamp; }
    public void setTimestamp(Long timestamp) { this.timestamp = timestamp; }
}
