package com.davos.assessment.project;

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

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

  @Column(nullable = false, unique = true)
  private String slug;

  @Column(nullable = false)
  private String name;

  @Column(name = "landing_title", nullable = false)
  private String landingTitle;

  @Column(name = "landing_description", nullable = false, columnDefinition = "text")
  private String landingDescription;

  @Column(name = "report_title", nullable = false)
  private String reportTitle;

  @Column(name = "logo_url", nullable = false, columnDefinition = "text")
  private String logoUrl = "";

  @Column(nullable = false)
  private boolean enabled = true;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "created_by")
  private AppUser createdBy;

  @Column(name = "created_at", nullable = false)
  private Instant createdAt = Instant.now();

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

  public Long getId() { return id; }
  public String getSlug() { return slug; }
  public void setSlug(String slug) { this.slug = slug; }
  public String getName() { return name; }
  public void setName(String name) { this.name = name; }
  public String getLandingTitle() { return landingTitle; }
  public void setLandingTitle(String landingTitle) { this.landingTitle = landingTitle; }
  public String getLandingDescription() { return landingDescription; }
  public void setLandingDescription(String landingDescription) { this.landingDescription = landingDescription; }
  public String getReportTitle() { return reportTitle; }
  public void setReportTitle(String reportTitle) { this.reportTitle = reportTitle; }
  public String getLogoUrl() { return logoUrl; }
  public void setLogoUrl(String logoUrl) { this.logoUrl = logoUrl == null ? "" : logoUrl; }
  public boolean isEnabled() { return enabled; }
  public void setEnabled(boolean enabled) { this.enabled = enabled; }
  public AppUser getCreatedBy() { return createdBy; }
  public void setCreatedBy(AppUser createdBy) { this.createdBy = createdBy; }
  public Instant getCreatedAt() { return createdAt; }
  public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
  public Instant getUpdatedAt() { return updatedAt; }
  public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; }
}
