package com.walkguide.entity;

import com.walkguide.enums.HardwareShortcutKey;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;

@Entity
@Table(name = "hardware_shortcuts")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HardwareShortcut {

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

    @Column(name = "guardian_id")
    private Long guardianId;

    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Enumerated(EnumType.STRING)
    @Column(name = "shortcut_key", nullable = false)
    private HardwareShortcutKey shortcutKey;

    @Column(name = "button_name", length = 100)
    private String buttonName;

    @Column(name = "button_code")
    private Integer buttonCode;

    @Column(nullable = false)
    @Builder.Default
    private Boolean enabled = true;

    @Column(name = "updated_at", nullable = false)
    private LocalDateTime updatedAt;

    @PrePersist
    @PreUpdate
    protected void onUpdate() {
        updatedAt = LocalDateTime.now();
    }
}
