package de.cannamanage.domain.entity;

import jakarta.persistence.*;

import java.time.Instant;
import java.util.UUID;

/**
 * Forum reply entity — a response to a forum topic.
 * Content stored as HTML. Replies can be edited within a 60-minute window.
 */
@Entity
@Table(name = "forum_replies", indexes = {
    @Index(name = "idx_forum_replies_topic_id", columnList = "topic_id"),
    @Index(name = "idx_forum_replies_tenant_id", columnList = "tenant_id")
})
public class ForumReply extends AbstractTenantEntity {

    @Column(name = "topic_id", nullable = false)
    private UUID topicId;

    @Column(name = "club_id", nullable = false)
    private UUID clubId;

    @Column(name = "content", nullable = false, columnDefinition = "TEXT")
    private String content;

    @Column(name = "author_id", nullable = false)
    private UUID authorId;

    @Column(name = "is_edited", nullable = false)
    private boolean edited = false;

    @Column(name = "edited_at")
    private Instant editedAt;

    public ForumReply() {}

    public ForumReply(UUID topicId, UUID clubId, String content, UUID authorId) {
        this.topicId = topicId;
        this.clubId = clubId;
        this.content = content;
        this.authorId = authorId;
    }

    // Getters and setters

    public UUID getTopicId() { return topicId; }
    public void setTopicId(UUID topicId) { this.topicId = topicId; }

    public UUID getClubId() { return clubId; }
    public void setClubId(UUID clubId) { this.clubId = clubId; }

    public String getContent() { return content; }
    public void setContent(String content) { this.content = content; }

    public UUID getAuthorId() { return authorId; }
    public void setAuthorId(UUID authorId) { this.authorId = authorId; }

    public boolean isEdited() { return edited; }
    public void setEdited(boolean edited) { this.edited = edited; }

    public Instant getEditedAt() { return editedAt; }
    public void setEditedAt(Instant editedAt) { this.editedAt = editedAt; }
}
