package com.gyee.wisdom.dao.sql.alarm.Entity;

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.alarm.Alerthistory;
import com.gyee.wisdom.common.data.alarm.AlerthistoryNew;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.beans.BeanUtils;

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

@Data
@NoArgsConstructor
@Entity
@Table(name = "alerthistory_new")
//@GenericGenerator(name = "NXFD_ALERTHISTORY_NEW", strategy = "NXFD_ALERTHISTORY_NEW")
public class AlerthistoryNewEntity implements ToData<AlerthistoryNew>,Serializable{

    private static final long serialVersionUID = -9116357102786246345L;
    @Id
    @Column(name = "id")
//    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "NXFD_ALERTHISTORY_NEW")
//    @SequenceGenerator(name = "NXFD_ALERTHISTORY_NEW", sequenceName = "NXFD_ALERTHISTORY_NEW")
    private Long id;
    @Column(name = "alerttime")
    private Date alertTime;
    @Column(name = "messagetype")
    private int messageType;
    @Column(name = "operator")
    private String operator;
    @Column(name = "snapid")
    private Long snapId;
    @Column(name = "isconfirmed")
    private Integer isConfirmed;
    @Column(name = "confirmtime")
    private Date confirmTime;
    @Column(name = "confirmperson")
    private String confirmPerson;
    @Column(name = "datainfo")
    private String dataInfo;

    @Override
    public AlerthistoryNew toData() {
        if(this!=null) {
            AlerthistoryNew alerthistory = new AlerthistoryNew();
            BeanUtils.copyProperties(this, alerthistory);
            return alerthistory;
        }else {
            return null;
        }
    }

    public AlerthistoryNewEntity(AlerthistoryNew alerthistory){

        this.id = alerthistory.getId();
        this.alertTime = alerthistory.getAlertTime();
        this.messageType =alerthistory.getMessageType();
        this.operator = alerthistory.getOperator();
        this.snapId =alerthistory.getSnapId();
        this.isConfirmed = alerthistory.getIsConfirmed();
        this.confirmTime = alerthistory.getConfirmTime();
        this.confirmPerson = alerthistory.getConfirmPerson();
        this.dataInfo =alerthistory.getDataInfo();

    }


}
