package com.walkguide.entity;

import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;

@Entity
@Table(name = "user_settings")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserSettings {

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

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

    @Column(name = "tts_language", nullable = false)
    @Builder.Default
    private String ttsLanguage = "id-ID";

    @Column(name = "tts_pitch", nullable = false)
    @Builder.Default
    private Double ttsPitch = 1.0;

    @Column(name = "tts_speed", nullable = false)
    @Builder.Default
    private Double ttsSpeed = 0.9;

    @Column(name = "warn_no_guardian", nullable = false)
    @Builder.Default
    private Boolean warnNoGuardian = true;

    @Column(name = "haptic_enabled", nullable = false)
    @Builder.Default
    private Boolean hapticEnabled = true;

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

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