package com.rongyichuang.activity.repository;
|
|
import com.rongyichuang.activity.entity.ActivityPlayerRating;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.repository.query.Param;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.List;
|
import java.util.Optional;
|
|
/**
|
* 活动选手评分数据访问层
|
*/
|
@Repository
|
public interface ActivityPlayerRatingRepository extends JpaRepository<ActivityPlayerRating, Long> {
|
|
/**
|
* 根据活动选手ID和评委ID查找评分记录
|
*/
|
Optional<ActivityPlayerRating> findByActivityPlayerIdAndJudgeId(Long activityPlayerId, Long judgeId);
|
|
/**
|
* 根据活动选手ID查找所有评分记录
|
*/
|
List<ActivityPlayerRating> findByActivityPlayerId(Long activityPlayerId);
|
|
/**
|
* 根据活动ID查找所有评分记录
|
*/
|
List<ActivityPlayerRating> findByActivityId(Long activityId);
|
|
/**
|
* 根据评委ID查找所有评分记录
|
*/
|
List<ActivityPlayerRating> findByJudgeId(Long judgeId);
|
|
/**
|
* 根据选手ID查找所有评分记录
|
*/
|
List<ActivityPlayerRating> findByPlayerId(Long playerId);
|
|
/**
|
* 检查指定评委是否已对指定选手评分
|
*/
|
boolean existsByActivityPlayerIdAndJudgeId(Long activityPlayerId, Long judgeId);
|
|
/**
|
* 统计指定活动选手的评分数量
|
*/
|
@Query("SELECT COUNT(r) FROM ActivityPlayerRating r WHERE r.activityPlayerId = :activityPlayerId AND r.status = 1")
|
long countCompletedRatingsByActivityPlayerId(@Param("activityPlayerId") Long activityPlayerId);
|
|
/**
|
* 获取指定活动选手的所有已完成评分
|
*/
|
@Query("SELECT r FROM ActivityPlayerRating r WHERE r.activityPlayerId = :activityPlayerId AND r.status = 1")
|
List<ActivityPlayerRating> findCompletedRatingsByActivityPlayerId(@Param("activityPlayerId") Long activityPlayerId);
|
|
/**
|
* 根据活动ID和评委ID查找评分记录
|
*/
|
List<ActivityPlayerRating> findByActivityIdAndJudgeId(Long activityId, Long judgeId);
|
|
/**
|
* 删除指定活动选手的指定评委评分记录
|
*/
|
void deleteByActivityPlayerIdAndJudgeId(Long activityPlayerId, Long judgeId);
|
}
|