package com.davos.assessment.project;

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

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

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

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

  @Enumerated(EnumType.STRING)
  @Column(nullable = false)
  private ProjectMembershipRole role;

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

  @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 ProjectMembershipRole getRole() { return role; }
  public void setRole(ProjectMembershipRole role) { this.role = role; }
  public boolean isEnabled() { return enabled; }
  public void setEnabled(boolean enabled) { this.enabled = enabled; }
  public Instant getCreatedAt() { return createdAt; }
}
