Skip to content

Commit b79c30a

Browse files
[Feature] add findToursByIds() to CompetitionFacade (#563)
1 parent e6f6502 commit b79c30a

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/main/java/com/itasocialacademy/oitassist/competition/api/CompetitionFacade.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,15 @@ public interface CompetitionFacade {
5959
* @return the competition tree, or empty if no competition with this ID exists
6060
*/
6161
Optional<CompetitionTreeDetail> findCompetitionTreeByCompetitionId(Long competitionId);
62+
63+
/**
64+
* Retrieves tours by their IDs.
65+
*
66+
* @param tourIds Tour IDs, must not be {@code null} (an empty list yields an
67+
* empty result)
68+
* @return the tours found for the given IDs, in unspecified order; IDs with no
69+
* matching tour are silently omitted, so the result may be smaller than
70+
* {@code tourIds}
71+
*/
72+
List<TourDetail> findToursByIds(List<Long> tourIds);
6273
}

src/main/java/com/itasocialacademy/oitassist/competition/service/CompetitionFacadeImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ public Optional<CompetitionTreeDetail> findCompetitionTreeByCompetitionId(Long c
7878
.map(this::buildTreeDetail);
7979
}
8080

81+
@Override
82+
@Transactional(readOnly = true)
83+
public List<TourDetail> findToursByIds(List<Long> tourIds) {
84+
Objects.requireNonNull(tourIds, "tourIds must not be null");
85+
if (tourIds.isEmpty()) {
86+
return List.of();
87+
}
88+
return tourRepository.findAllById(tourIds).stream()
89+
.map(tourMapper::toTourDetail)
90+
.toList();
91+
}
92+
8193
private CompetitionTreeDetail buildTreeDetail(Competition competitionEntity) {
8294
CompetitionDetail competitionDetail = competitionMapper.toCompetitionDetail(competitionEntity);
8395

0 commit comments

Comments
 (0)