JAVA/Spring Boot
(Spring Boot)Entity에 있는 리스트 조회 제한하기
ri5
2021. 7. 8. 13:29
문제점
너무 많은 태그들이 나와서 태그 개수를 제한해야함.
해결책
public GameLimitTagListResponseDto(Game entity) {
this.gameId = entity.getGameId();
this.gameName = entity.getGameName();
this.gameInfo = entity.getGameInfo();
this.launchDate = entity.getLaunchDate();
this.evaluation = entity.getEvaluation();
this.imgUrl = entity.getImgUrl();
this.videoUrl = entity.getVideoUrl();
this.devCompany = entity.getDevCompany();
this.distributor = entity.getDistributor();
this.gameTags = entity.getGameTags().stream().limit(2L).map(GameTag::getTag).collect(Collectors.toList());
}
entity.stream().limit으로 데이터 개수를 제한함