package com.rongyichuang.judge.repository;
|
|
import com.rongyichuang.judge.entity.Judge;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
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 JudgeRepository extends JpaRepository<Judge, Long>, JpaSpecificationExecutor<Judge> {
|
|
@Query("SELECT j FROM Judge j WHERE j.name LIKE %:name%")
|
List<Judge> findByNameContaining(@Param("name") String name);
|
|
boolean existsByPhone(String phone);
|
|
/**
|
* 根据用户ID查找评委
|
*/
|
Optional<Judge> findByUserId(Long userId);
|
|
/**
|
* 检查评委是否参与指定活动
|
*/
|
@Query("SELECT COUNT(aj) > 0 FROM ActivityJudge aj WHERE aj.judgeId = :judgeId AND aj.activityId = :activityId")
|
boolean existsByIdAndActivityId(@Param("judgeId") Long judgeId, @Param("activityId") Long activityId);
|
|
/**
|
* 根据状态统计评委数量
|
*/
|
long countByState(Integer state);
|
}
|