package com.davos.assessment.legal;

import com.davos.assessment.user.AppUser;
import com.davos.assessment.project.Project;
import jakarta.persistence.*;
import java.time.Instant;

@Entity
@Table(name = "legal_documents")
public class LegalDocument {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Enumerated(EnumType.STRING)
  @Column(name = "doc_type", nullable = false)
  private LegalDocumentType docType;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "project_id", nullable = false)
  private Project project;

  @Column(nullable = false)
  private String version;

  @Column(nullable = false)
  private String title;

  @Column(name = "content_md", columnDefinition = "text", nullable = false)
  private String contentMd;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "updated_by")
  private AppUser updatedBy;

  @Column(name = "updated_at", nullable = false)
  private Instant updatedAt = Instant.now();

  public Long getId() { return id; }
  public Project getProject() { return project; }
  public void setProject(Project project) { this.project = project; }
  public LegalDocumentType getDocType() { return docType; }
  public void setDocType(LegalDocumentType docType) { this.docType = docType; }
  public String getVersion() { return version; }
  public void setVersion(String version) { this.version = version; }
  public String getTitle() { return title; }
  public void setTitle(String title) { this.title = title; }
  public String getContentMd() { return contentMd; }
  public void setContentMd(String contentMd) { this.contentMd = contentMd; }
  public AppUser getUpdatedBy() { return updatedBy; }
  public void setUpdatedBy(AppUser updatedBy) { this.updatedBy = updatedBy; }
  public Instant getUpdatedAt() { return updatedAt; }
  public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; }
}
