package com.bytesw.bytebot.model;

import com.bytesw.bytebot.model.converters.FrequentQuestionStatusConverter;
import com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author Sebastian Chicoma Sandmann
 * @version 09-sep-2020
 *
 * Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
 *
 * Este software constituye información confidencial y propietaria de Byte, S.A.
 * ("Información Confidencial"). Usted no debe develar dicha Información
 * Confidencial y debe usarla de acuerdo con los términos de aceptación de
 * licencia de uso que firmó con Byte.
 */
@Audited
@Entity
@Table(name = "AVB_FREQUENT_QUESTION")
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "id")
@NamedQuery(name = "FrequentQuestion.findByPK", query = "Select u from FrequentQuestion u where u.id = ?1")
public class FrequentQuestion {
    @Id
    @Column(name = "FQUE_ID")
    @SequenceGenerator(name = "AVB_FREQUENT_QUESTION_GENERATOR", sequenceName = "AVB_FREQUENT_QUESTION_SEQ", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_FREQUENT_QUESTION_GENERATOR")
    private Long id;

    @Column(name = "FQUE_UUID")
    private String uuid;

    @Column(name = "FQUE_NAME")
    private String filename;

    @Column(name = "FQUE_DESC")
    private String description;

    @Column(name = "FQUE_STATE")
    @Convert(converter = FrequentQuestionStatusConverter.class)
    private FrequentQuestionStatusEnum status;

    @ManyToOne
    @JoinColumn(name = "AGEN_ID", referencedColumnName = "AGEN_ID")
    private Agent agent;

    @Column(name = "FQUE_USER")
    private String user;

    @Column(name = "FQUE_LDATE", columnDefinition = "TIMESTAMP")
    private LocalDateTime uploadDate;

}
