package com.example.computers.entity;

import jakarta.persistence.*;

@Entity
@Table(name = "computer")
public class Computer {

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

    @Column(name = "inventory_number", unique = true, nullable = false)
    private String inventoryNumber;

    private String model;

    @Column(name = "serial_number")
    private String serialNumber;

    private Integer year;

    private String status; // В работе, На ремонте, Списан

    // Связь с производителем
    @ManyToOne
    @JoinColumn(name = "manufacturer_id")
    private Manufacturer manufacturer;

    // Связь с локацией
    @ManyToOne
    @JoinColumn(name = "location_id")
    private Location location;

    // ======= Конструкторы =======
    public Computer() {
    }

    public Computer(Long id, String inventoryNumber, String model, String serialNumber, Integer year,
                    String status, Manufacturer manufacturer, Location location) {
        this.id = id;
        this.inventoryNumber = inventoryNumber;
        this.model = model;
        this.serialNumber = serialNumber;
        this.year = year;
        this.status = status;
        this.manufacturer = manufacturer;
        this.location = location;
    }

    // ======= Геттеры и сеттеры =======
    public Long getId() {
        return id;
    }

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

    public String getInventoryNumber() {
        return inventoryNumber;
    }

    public void setInventoryNumber(String inventoryNumber) {
        this.inventoryNumber = inventoryNumber;
    }

    public String getModel() {
        return model;
    }

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

    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Manufacturer getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(Manufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    // ======= toString =======
    @Override
    public String toString() {
        return "Computer{" +
                "id=" + id +
                ", inventoryNumber='" + inventoryNumber + '\'' +
                ", model='" + model + '\'' +
                ", serialNumber='" + serialNumber + '\'' +
                ", year=" + year +
                ", status='" + status + '\'' +
                '}';
    }
}