package dev.lions.unionflow.server.entity.gouvernance;

import dev.lions.unionflow.server.api.enums.gouvernance.NiveauEchelon;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;

@Entity
@Table(name = "echelons_organigramme", indexes = {
        @Index(name = "idx_echelon_org", columnList = "organisation_id"),
        @Index(name = "idx_echelon_parent", columnList = "echelon_parent_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class EchelonOrganigramme extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "organisation_id", nullable = false)
    private Organisation organisation;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "echelon_parent_id")
    private Organisation echelonParent;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "niveau_echelon", nullable = false, length = 50)
    private NiveauEchelon niveau;

    @NotBlank
    @Column(name = "designation", nullable = false, length = 200)
    private String designation;

    @Column(name = "zone_delegation", length = 200)
    private String zoneGeographiqueOuDelegation;
}
