You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
1.0 KiB
24 lines
1.0 KiB
package com.gym.repository;
|
|
|
|
import com.gym.model.TrainingPlan;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.stereotype.Repository;
|
|
import java.util.List;
|
|
|
|
@Repository
|
|
public interface TrainingPlanRepository extends JpaRepository<TrainingPlan, Long> {
|
|
List<TrainingPlan> findByMemberId(Long memberId);
|
|
List<TrainingPlan> findByCoachId(Long coachId);
|
|
List<TrainingPlan> findByStatus(String status);
|
|
List<TrainingPlan> findByGoal(String goal);
|
|
|
|
@Query("SELECT tp FROM TrainingPlan tp WHERE tp.member.id = ?1 AND tp.status = 'ACTIVE'")
|
|
List<TrainingPlan> findActivePlansByMember(Long memberId);
|
|
|
|
@Query("SELECT tp FROM TrainingPlan tp WHERE tp.coach.id = ?1 AND tp.status = 'ACTIVE'")
|
|
List<TrainingPlan> findActivePlansByCoach(Long coachId);
|
|
|
|
@Query("SELECT COUNT(tp) FROM TrainingPlan tp WHERE tp.member.id = ?1 AND tp.status = 'COMPLETED'")
|
|
Long countCompletedPlansByMember(Long memberId);
|
|
} |