package com.zd.laboratory.mqtt.entiy;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 发送请求体
 * @Author: zhoupan
 * @Date: 2021/10/08/10:46
 * @Description:
 */
public class MessageBody<T> {

    public static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    T data;

    String msg;

    String sendDate;

    Integer type;

    Long messageId;

    public MessageBody() {
        //获取当前时间
        LocalDateTime newTime = LocalDateTime.now();
        String format = formatter.format(newTime);
        this.sendDate = format;
    }

    public MessageBody(String msg) {
        LocalDateTime newTime = LocalDateTime.now();
        String format = formatter.format(newTime);
        this.sendDate = format;
        this.msg = msg;
    }

    public MessageBody(String msg, Integer type) {
        LocalDateTime newTime = LocalDateTime.now();
        String format = formatter.format(newTime);
        this.sendDate = format;
        this.msg = msg;
        this.type = type;
    }

    public MessageBody(String msg, Integer type, Long messageId) {
        LocalDateTime newTime = LocalDateTime.now();
        String format = formatter.format(newTime);
        this.sendDate = format;
        this.msg = msg;
        this.type = type;
        this.messageId = messageId;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getSendDate() {
        return sendDate;
    }

    public void setSendDate(String sendDate) {
        this.sendDate = sendDate;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getMessageId() {
        return messageId;
    }

    public void setMessageId(Long messageId) {
        this.messageId = messageId;
    }
}
