package de.cannamanage.domain.entity;

import de.cannamanage.domain.enums.ForumTargetType;
import de.cannamanage.domain.enums.ReportStatus;
import jakarta.persistence.*;

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

/**
 * Forum report entity — allows members to report inappropriate content.
 * Reporter identity is protected: reporterId is NOT exposed in public DTOs (only visible to moderators).
 */
@Entity
@Table(name = "forum_reports", indexes = {
    @Index(name = "idx_forum_reports_club_status", columnList = "club_id, status"),
    @Index(name = "idx_forum_reports_tenant_id", columnList = "tenant_id")
})
public class ForumReport extends AbstractTenantEntity {

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

    @Enumerated(EnumType.STRING)
    @Column(name = "target_type", nullable = false, length = 10)
    private ForumTargetType targetType;

    @Column(name = "target_id", nullable = false)
    private UUID targetId;

    @Column(name = "reporter_id", nullable = false)
    private UUID reporterId;

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

    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private ReportStatus status = ReportStatus.OPEN;

    @Column(name = "reviewed_by")
    private UUID reviewedBy;

    @Column(name = "reviewed_at")
    private Instant reviewedAt;

    public ForumReport() {}

    public ForumReport(UUID clubId, ForumTargetType targetType, UUID targetId, UUID reporterId, String reason) {
        this.clubId = clubId;
        this.targetType = targetType;
        this.targetId = targetId;
        this.reporterId = reporterId;
        this.reason = reason;
        this.status = ReportStatus.OPEN;
    }

    // Getters and setters

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

    public ForumTargetType getTargetType() { return targetType; }
    public void setTargetType(ForumTargetType targetType) { this.targetType = targetType; }

    public UUID getTargetId() { return targetId; }
    public void setTargetId(UUID targetId) { this.targetId = targetId; }

    public UUID getReporterId() { return reporterId; }
    public void setReporterId(UUID reporterId) { this.reporterId = reporterId; }

    public String getReason() { return reason; }
    public void setReason(String reason) { this.reason = reason; }

    public ReportStatus getStatus() { return status; }
    public void setStatus(ReportStatus status) { this.status = status; }

    public UUID getReviewedBy() { return reviewedBy; }
    public void setReviewedBy(UUID reviewedBy) { this.reviewedBy = reviewedBy; }

    public Instant getReviewedAt() { return reviewedAt; }
    public void setReviewedAt(Instant reviewedAt) { this.reviewedAt = reviewedAt; }
}
