package com.rongyichuang.dashboard.service; import com.rongyichuang.activity.repository.ActivityRepository; import com.rongyichuang.judge.repository.JudgeRepository; import com.rongyichuang.player.repository.ActivityPlayerRepository; import com.rongyichuang.player.repository.PlayerRepository; import com.rongyichuang.dashboard.dto.response.DashboardStatsResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Dashboard 统计数据服务 */ @Service public class DashboardService { @Autowired private ActivityRepository activityRepository; @Autowired private PlayerRepository playerRepository; @Autowired private ActivityPlayerRepository activityPlayerRepository; @Autowired private JudgeRepository judgeRepository; /** * 获取Dashboard统计数据 */ public DashboardStatsResponse getDashboardStats() { DashboardStatsResponse stats = new DashboardStatsResponse(); // 当前进行比赛数量(状态为1的比赛,pid=0表示主比赛) long activeActivities = activityRepository.countActiveActivities(); stats.setActiveActivities((int) activeActivities); // 参赛总人数(状态为1的选手) long totalPlayers = playerRepository.countByState(1); stats.setTotalPlayers((int) totalPlayers); // 报名待审核人数(activityPlayer状态为1表示待审核) long pendingReviews = activityPlayerRepository.countByState(1); stats.setPendingReviews((int) pendingReviews); // 评委总数(状态为1的评委) long totalJudges = judgeRepository.countByState(1); stats.setTotalJudges((int) totalJudges); return stats; } }