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 = "consent_logs")
public class ConsentLog {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "user_id", nullable = false)
  private AppUser user;

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

  @Enumerated(EnumType.STRING)
  @Column(name = "consent_type", nullable = false)
  private ConsentType consentType;

  @Column(name = "consent_version", nullable = false)
  private String consentVersion;

  @Column(nullable = false)
  private boolean granted;

  @Column(name = "ip_address", nullable = false)
  private String ipAddress;

  @Column(name = "user_agent", columnDefinition = "text", nullable = false)
  private String userAgent;

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

  public Long getId() { return id; }
  public Project getProject() { return project; }
  public void setProject(Project project) { this.project = project; }
  public AppUser getUser() { return user; }
  public void setUser(AppUser user) { this.user = user; }
  public ConsentType getConsentType() { return consentType; }
  public void setConsentType(ConsentType consentType) { this.consentType = consentType; }
  public String getConsentVersion() { return consentVersion; }
  public void setConsentVersion(String consentVersion) { this.consentVersion = consentVersion; }
  public boolean isGranted() { return granted; }
  public void setGranted(boolean granted) { this.granted = granted; }
  public String getIpAddress() { return ipAddress; }
  public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
  public String getUserAgent() { return userAgent; }
  public void setUserAgent(String userAgent) { this.userAgent = userAgent; }
  public Instant getCreatedAt() { return createdAt; }
  public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
}
