AppNotification.java

package com.wavii.model;

import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * Entidad que representa una notificación interna enviada a un usuario.
 * Contiene el título, cuerpo, tipo y datos adicionales en formato JSON.
 */
@Entity
@Table(name = "app_notifications")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppNotification {

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

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "recipient_id", nullable = false)
    private User recipient;

    @Column(length = 40, nullable = false)
    private String type;

    @Column(length = 160, nullable = false)
    private String title;

    @Column(length = 500, nullable = false)
    private String body;

    @Column(length = 1200)
    private String dataJson;

    @Column(nullable = false)
    @Builder.Default
    private boolean read = false;

    @Column(nullable = false, updatable = false)
    @Builder.Default
    private LocalDateTime createdAt = LocalDateTime.now();
}