package com.example.computers.entity;

import jakarta.persistence.*;

@Entity
@Table(name = "component")
public class Component {

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

    private String type; // CPU, RAM, SSD, GPU
    private String model;

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

    public Component() { }

    public Component(Long id, String type, String model, Computer computer) {
        this.id = id;
        this.type = type;
        this.model = model;
        this.computer = computer;
    }

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

    public String getType() { return type; }
    public void setType(String type) { this.type = type; }

    public String getModel() { return model; }
    public void setModel(String model) { this.model = model; }

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

    @Override
    public String toString() {
        return type + " - " + model;
    }
}