lrj
4 天以前 4fa9591629721797386fc11836e3a9deb69cd58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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);
}