package com.uas.search.jms;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 用于实时更新的消息
 *
 * @author sunyj
 * @since 2017/10/11 16:12
 */
@Entity
@Table(name = "lucene$message")
public class LuceneMessage implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Id
    @Column(name = "me_id")
    private Long id;

    /**
     * 表名
     */
    @Column(name = "me_table_name")
    private String tableName;

    /**
     * 更改类型
     */
    @Column(name = "me_method_type")
    private String methodType;

    /**
     * 数据 id
     */
    @Column(name = "me_data_id")
    private Long dataId;

    /**
     * 数据，可为空
     */
    @Column(name = "me_data")
    private String data;

    /**
     * 优先级
     */
    @Column(name = "me_priority")
    private Long priority;

    /**
     * 尝试次数
     */
    @Column(name = "me_retry_count")
    private Long retryCount;

    /**
     * 时间
     */
    @Column(name = "me_create_time")
    private Date createTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getMethodType() {
        return methodType;
    }

    public void setMethodType(String methodType) {
        this.methodType = methodType;
    }

    public Long getDataId() {
        return dataId;
    }

    public void setDataId(Long dataId) {
        this.dataId = dataId;
    }

    public String getData() {
        return data;
    }

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

    public Long getPriority() {
        return priority;
    }

    public void setPriority(Long priority) {
        this.priority = priority;
    }

    public Long getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(Long retryCount) {
        this.retryCount = retryCount;
    }

    public String getCreateTime() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "LuceneMessage{" +
                "id=" + id +
                ", tableName='" + tableName + '\'' +
                ", methodType='" + methodType + '\'' +
                ", dataId=" + dataId +
                ", data='" + data + '\'' +
                ", priority=" + priority +
                ", retryCount=" + retryCount +
                ", createTime=" + createTime +
                '}';
    }
}

