package de.cannamanage.domain.entity;

import jakarta.persistence.*;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.UUID;

@Entity
@Table(name = "feeding_logs")
public class FeedingLog {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    @Column(name = "id", nullable = false, updatable = false)
    private UUID id;

    @Column(name = "grow_entry_id", nullable = false)
    private UUID growEntryId;

    @Column(name = "nutrient_name", nullable = false, length = 100)
    private String nutrientName;

    @Column(name = "amount_ml", nullable = false, precision = 8, scale = 1)
    private BigDecimal amountMl;

    @Column(name = "water_liters", precision = 8, scale = 1)
    private BigDecimal waterLiters;

    @Column(name = "ph_after", precision = 4, scale = 2)
    private BigDecimal phAfter;

    @Column(name = "ec_after", precision = 6, scale = 2)
    private BigDecimal ecAfter;

    @Column(name = "fed_at", nullable = false)
    private Instant fedAt;

    @Column(name = "notes", columnDefinition = "TEXT")
    private String notes;

    @PrePersist
    void onCreate() {
        if (this.fedAt == null) this.fedAt = Instant.now();
    }

    public UUID getId() { return id; }
    public void setId(UUID id) { this.id = id; }

    public UUID getGrowEntryId() { return growEntryId; }
    public void setGrowEntryId(UUID growEntryId) { this.growEntryId = growEntryId; }

    public String getNutrientName() { return nutrientName; }
    public void setNutrientName(String nutrientName) { this.nutrientName = nutrientName; }

    public BigDecimal getAmountMl() { return amountMl; }
    public void setAmountMl(BigDecimal amountMl) { this.amountMl = amountMl; }

    public BigDecimal getWaterLiters() { return waterLiters; }
    public void setWaterLiters(BigDecimal waterLiters) { this.waterLiters = waterLiters; }

    public BigDecimal getPhAfter() { return phAfter; }
    public void setPhAfter(BigDecimal phAfter) { this.phAfter = phAfter; }

    public BigDecimal getEcAfter() { return ecAfter; }
    public void setEcAfter(BigDecimal ecAfter) { this.ecAfter = ecAfter; }

    public Instant getFedAt() { return fedAt; }
    public void setFedAt(Instant fedAt) { this.fedAt = fedAt; }

    public String getNotes() { return notes; }
    public void setNotes(String notes) { this.notes = notes; }
}
