package com.davos.assessment.assessment;

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

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

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

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

  @ManyToOne(optional = false, fetch = FetchType.LAZY)
  @JoinColumn(name = "assessment_id", nullable = false)
  private Assessment assessment;

  @Column(name = "answers_json", nullable = false, columnDefinition = "text")
  private String answersJson = "{}";

  @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 AppUser getUser() { return user; }
  public void setUser(AppUser user) { this.user = user; }
  public Assessment getAssessment() { return assessment; }
  public void setAssessment(Assessment assessment) { this.assessment = assessment; }
  public String getAnswersJson() { return answersJson; }
  public void setAnswersJson(String answersJson) { this.answersJson = answersJson; }
  public Instant getUpdatedAt() { return updatedAt; }
  public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; }
}
