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

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.alarm.AlerthistoryNew;
import com.gyee.wisdom.common.data.alarm.FaultHistory;
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 = "faulthistory")
public class FaultHistoryEntity implements ToData<FaultHistory>,Serializable{

    private static final long serialVersionUID = -9116357102786444345L;
    @Id
    @Column(name = "id")
//    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_FAULTHISTORY")
//    @SequenceGenerator(name = "SEQ_FAULTHISTORY", sequenceName = "NXFD_FAULTHISTORY_ID")
    @GeneratedValue
    private Long id;
    @Column(name = "faulttime")
    private Date faultTime;
    @Column(name = "operator")
    private String operator;
    @Column(name = "snapid")
    private Long snapId;
    @Column(name = "confirmtype")
    private Integer confirmType;
    @Column(name = "confirmtime")
    private Date confirmTime;
    @Column(name = "confirmperson")
    private String confirmPerson;
    @Column(name = "messagetype")
    private int messageType;

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

    public FaultHistoryEntity(FaultHistory history){

        this.id = history.getId();
        this.faultTime = history.getFaultTime();
        this.operator = history.getOperator();
        this.snapId =history.getSnapId();
        this.confirmType = history.getConfirmType();
        this.confirmTime = history.getConfirmTime();
        this.confirmPerson = history.getConfirmPerson();
        this.messageType = history.getMessageType();

    }


}
