diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java index 5bbcde757..734b105df 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java @@ -21,8 +21,8 @@ default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final final Map applicantCountMapping = countApplicantsByRunnerPostIds(runnerPostIds) .stream() .collect(Collectors.toMap( - applicantCountDto -> applicantCountDto.getRunnerPostId(), - applicantCountDto -> applicantCountDto.getApplicantCount() + ApplicantCountDto::runnerPostId, + ApplicantCountDto::applicantCount )); return new ApplicantCountMappingDto(applicantCountMapping); @@ -34,7 +34,6 @@ default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final left outer join fetch SupporterRunnerPost srp on srp.runnerPost.id = rp.id where rp.id in :runnerPostIds group by rp.id - order by rp.id """) List countApplicantsByRunnerPostIds(@Param("runnerPostIds") final List runnerPostIds); diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java index 64bacb079..3191616c7 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java @@ -1,39 +1,4 @@ package touch.baton.domain.runnerpost.repository.dto; -import java.util.Objects; - -public class ApplicantCountDto { - - private Long runnerPostId; - - private Long applicantCount; - - public ApplicantCountDto() { - } - - public ApplicantCountDto(final Long runnerPostId, final Long applicantCount) { - this.runnerPostId = runnerPostId; - this.applicantCount = (long) applicantCount; - } - - public Long getRunnerPostId() { - return runnerPostId; - } - - public Long getApplicantCount() { - return applicantCount; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ApplicantCountDto that = (ApplicantCountDto) o; - return applicantCount == that.applicantCount && Objects.equals(runnerPostId, that.runnerPostId); - } - - @Override - public int hashCode() { - return Objects.hash(runnerPostId, applicantCount); - } +public record ApplicantCountDto(Long runnerPostId, Long applicantCount) { } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java index d37994659..64d26021b 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java @@ -1,34 +1,10 @@ package touch.baton.domain.runnerpost.repository.dto; import java.util.Map; -import java.util.Objects; -public class ApplicantCountMappingDto { - - private final Map applicantCounts; - - public ApplicantCountMappingDto(final Map applicantCounts) { - this.applicantCounts = applicantCounts; - } +public record ApplicantCountMappingDto(Map applicantCounts) { public Long getApplicantCountByRunnerPostId(final Long runnerPostId) { return applicantCounts.get(runnerPostId); } - - public Map getApplicantCounts() { - return applicantCounts; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ApplicantCountMappingDto that = (ApplicantCountMappingDto) o; - return Objects.equals(applicantCounts, that.applicantCounts); - } - - @Override - public int hashCode() { - return Objects.hash(applicantCounts); - } } diff --git a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java index d72b87374..3e1d5244d 100644 --- a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java +++ b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java @@ -13,6 +13,6 @@ default Long countApplicantByRunnerPostId(final Long runnerPostId) { throw new IllegalArgumentException("테스트에서 러너 게시글 식별자값으로 서포터 지원자 수 조회에 실패하였습니다."); } - return foundApplicants.get(0).getApplicantCount(); + return foundApplicants.get(0).applicantCount(); } }