package io.gmss.fiscad.entities.infocad.metier;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateTimeDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.enums.Origine;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import java.io.Serializable;
import java.time.LocalDateTime;

@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
//@SQLDelete(sql =
//        "UPDATE commentaire " +
//                "SET deleted = true " +
//                "WHERE id = ?")
//@Where(clause = " deleted = false")
public class Commentaire extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @JsonFormat(pattern = "dd-MM-yyyy HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime dateCommentaire;
    private Long idEnquete;
    private String commentaire;
    private String nomPrenom;
    @Enumerated(EnumType.STRING)
    private Origine origine;
    private String nupParcelle;
    @Column(name = "lu", nullable = false, columnDefinition = "BOOLEAN DEFAULT false")
    private boolean lu = false;
    @Column(name = "synchronise", nullable = false, columnDefinition = "BOOLEAN DEFAULT false")
    private boolean synchronise = false;
    private Long externalKey;
    private Long terminalId;
}
