package com.izouma.jmrh.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.izouma.jmrh.enums.ApprovalProcessStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ApprovalProcess extends BaseEntity {

    private Long userId;

    private Long approvalId;

    private int level;

    private String approver;

    @Enumerated(EnumType.STRING)
    private ApprovalProcessStatus status;

    private String remark;

    private LocalDateTime approvalTime;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "approvalId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    @NotFound(action = NotFoundAction.IGNORE)
    private Approval approval;
}
