package com.betriebsratkanzlei.legalconsenthub.notification

import com.betriebsratkanzlei.legalconsenthub.user.User
import com.betriebsratkanzlei.legalconsenthub_api.model.NotificationType
import jakarta.persistence.Column
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Entity
import jakarta.persistence.EntityListeners
import jakarta.persistence.Enumerated
import jakarta.persistence.EnumType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.Id
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.time.LocalDateTime
import java.util.UUID

@Entity
@EntityListeners(AuditingEntityListener::class)
class Notification(
    @Id
    @GeneratedValue
    var id: UUID? = null,

    @Column(nullable = false)
    var title: String = "",

    @Column(nullable = false, columnDefinition = "TEXT")
    var message: String = "",

    @Column(nullable = false)
    var clickTarget: String = "",

    @Column(nullable = false)
    var isRead: Boolean = false,

    @ManyToOne
    @JoinColumn(name = "recipient_id", nullable = true)
    var recipient: User?,

    @Column(nullable = false)
    var role: String = "",

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    var type: NotificationType = NotificationType.INFO,

    @Column(nullable = false)
    var organizationId: String = "",

    @CreatedDate
    @Column(nullable = false)
    var createdAt: LocalDateTime? = null
) 