| | |
| | | page = activityRepository.findByPidAndStateOrderByCreateTimeDesc(0L, state, pageable); |
| | | } |
| | | } else if (hasName) { |
| | | page = activityRepository.findByPidAndNameContainingOrderByCreateTimeDesc(0L, name, pageable); |
| | | // 当state为null但有名称搜索时,需要过滤掉已删除的比赛(state != 0) |
| | | page = activityRepository.findByPidAndStateNotAndNameContainingOrderByCreateTimeDesc(0L, 0, name, pageable); |
| | | } else { |
| | | // 查询所有主活动(pid = 0) |
| | | page = activityRepository.findByPidOrderByCreateTimeDesc(0L, pageable); |
| | | // 当state为null时,查询所有未删除的主活动(pid = 0 且 state != 0) |
| | | page = activityRepository.findByPidAndStateNotOrderByCreateTimeDesc(0L, 0, pageable); |
| | | } |
| | | |
| | | List<ActivityResponse> content = page.getContent().stream() |
| | | .map(activity -> { |
| | | ActivityResponse response = new ActivityResponse(activity); |
| | | // 设置参赛人数(只统计第一阶段的审核通过学员人数) |
| | | // 设置参赛人数(统计第一阶段的待审核和审核通过学员人数) |
| | | int playerCount = 0; |
| | | Activity firstStage = activityRepository.findFirstStageByActivityId(activity.getId()); |
| | | if (firstStage != null) { |
| | | // 如果有第一阶段,统计第一阶段的审核通过人数 |
| | | Long playerCountLong = activityPlayerRepository.countByStageIdAndState(firstStage.getId(), 1); |
| | | // 如果有第一阶段,统计第一阶段的待审核和审核通过人数 |
| | | Long playerCountLong = activityPlayerRepository.countByStageId(firstStage.getId()); |
| | | playerCount = playerCountLong != null ? playerCountLong.intValue() : 0; |
| | | } else { |
| | | // 如果没有阶段,统计活动本身的审核通过人数 |
| | | Long playerCountLong = activityPlayerRepository.countByActivityIdAndState(activity.getId(), 1); |
| | | // 如果没有阶段,统计活动本身的待审核和审核通过人数 |
| | | Long playerCountLong = activityPlayerRepository.countByActivityId(activity.getId()); |
| | | playerCount = playerCountLong != null ? playerCountLong.intValue() : 0; |
| | | } |
| | | response.setPlayerCount(playerCount); |