package com.davos.assessment.project;

import com.davos.assessment.user.AppUser;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ProjectMembershipRepository extends JpaRepository<ProjectMembership, Long> {
  Optional<ProjectMembership> findByProjectAndUser(Project project, AppUser user);
  Optional<ProjectMembership> findByProjectAndUserId(Project project, Long userId);
  List<ProjectMembership> findByProject(Project project);
  List<ProjectMembership> findByProjectAndRole(Project project, ProjectMembershipRole role);
  long countByProjectAndRole(Project project, ProjectMembershipRole role);
  long countByProjectAndRoleAndEnabledTrue(Project project, ProjectMembershipRole role);
}
