package com.walkguide.entity;

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

@Entity
@Table(name = "guardian_notifications")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GuardianNotification {

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

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

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

    @Enumerated(EnumType.STRING)
    @Column(name = "notif_type", nullable = false)
    @Builder.Default
    private NotificationType notifType = NotificationType.TEXT;

    @Column(columnDefinition = "TEXT")
    private String content;

    @Column(name = "voice_note_url", length = 500)
    private String voiceNoteUrl;

    @Column(name = "voice_note_duration")
    private Integer voiceNoteDuration;

    @Column(name = "is_read", nullable = false)
    @Builder.Default
    private Boolean isRead = false;

    @Column(name = "read_at")
    private LocalDateTime readAt;

    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
    }
}
