package de.nilzbu.mytimetracker.model;

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

import java.time.LocalDate;
import java.time.LocalTime;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(
        name = "time_entries",
        uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "date"})
)
public class TimeEntry {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "user_id", nullable = false)
    private User user;

    @NotNull
    private LocalDate date;

    private LocalTime startTime;

    private LocalTime endTime;

    /**
     * Pausenzeit in Minuten
     */
    private int pauseMinutes;

    /**
     * Sollarbeitszeit in Minuten
     */
    private int targetMinutes;

    /**
     * Status des Tages (normal, krank, Urlaub usw.)
     */
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private DayStatus status = DayStatus.REMOTE;

    private String comment;
}