package io.gmss.fiscad.entities.decoupage;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.parametre.Bloc;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class SecteurDecoupage extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate dateDebut;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate dateFin;

    @JsonBackReference
    @ManyToOne
    private Secteur secteur;

    @ManyToOne
    private Arrondissement arrondissement;

    @ManyToOne
    private Quartier quartier;

//    @JsonIgnore
//    @OneToMany(mappedBy = "secteurDecoupage")
//    private List<Bloc> blocs;

}