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 grau salarial dentro de uma categoria.
 */
@Entity
@Table(name = "salary_grade", indexes = {
    @Index(name = "idx_salary_grade_code", columnList = "code"),
    @Index(name = "idx_salary_grade_category", columnList = "category_id")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SalaryGrade extends AuditableEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id", nullable = false)
    private SalaryCategory category;

    @Column(nullable = false, length = 50)
    private String code;

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

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

