package com.walkguide.entity;

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

@Entity
@Table(name = "voice_command_configs")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class VoiceCommandConfig {

    @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 = "command_key", nullable = false)
    private VoiceCommandKey commandKey;

    @Column(name = "trigger_phrase", nullable = false, length = 200)
    private String triggerPhrase;

    @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();
    }
}
