package br.gov.sigefp.rh.domain;

import br.gov.sigefp.common.domain.AuditableEntity;
import jakarta.persistence.*;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Entidade que representa um nível (step) dentro de um grau salarial.
 */
@Entity
@Table(name = "salary_step", indexes = {
    @Index(name = "idx_salary_step_grade", columnList = "grade_id"),
    @Index(name = "idx_salary_step_number", columnList = "grade_id,step_number")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SalaryStep extends AuditableEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "grade_id", nullable = false)
    private SalaryGrade grade;

    @Column(nullable = false, name = "step_number")
    private Integer stepNumber; // Número do nível (1, 2, 3, etc.)

    @OneToMany(mappedBy = "step", cascade = CascadeType.ALL, orphanRemoval = true)
    @Builder.Default
    private List<SalaryGrid> grids = new ArrayList<>();
}

