package com.example.computers.entity;

import jakarta.persistence.*;
import java.time.LocalDate;

@Entity
@Table(name = "repair")
public class Repair {

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

    private LocalDate repairDate;
    private String description;
    private Double cost;

    @ManyToOne
    @JoinColumn(name = "computer_id")
    private Computer computer;

    public Repair() { }

    public Repair(Long id, LocalDate repairDate, String description, Double cost, Computer computer) {
        this.id = id;
        this.repairDate = repairDate;
        this.description = description;
        this.cost = cost;
        this.computer = computer;
    }

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

    public LocalDate getRepairDate() { return repairDate; }
    public void setRepairDate(LocalDate repairDate) { this.repairDate = repairDate; }

    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }

    public Double getCost() { return cost; }
    public void setCost(Double cost) { this.cost = cost; }

    public Computer getComputer() { return computer; }
    public void setComputer(Computer computer) { this.computer = computer; }

    @Override
    public String toString() {
        return repairDate + " - " + description + " ($" + cost + ")";
    }
}