Skip to content

Commit 349b0b4

Browse files
authored
Merge pull request #25 from DevKor-github/fix/get-participant
fix: 참가자 중복 표시되는 문제 해결
2 parents 6d0ed4f + f950586 commit 349b0b4

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/main/java/com/ODG/ODG_back/dto/participant/response/ParticipantListResponseDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public class ParticipantListResponseDto {
1515
private TransportType transportType;
1616
private BigDecimal lat;
1717
private BigDecimal lng;
18+
private String address;
1819
private boolean hasVoted;
1920
}

src/main/java/com/ODG/ODG_back/repository/ParticipantRepository.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ public interface ParticipantRepository extends JpaRepository<Participant, Long>
1616

1717
Optional<Participant> findByUserId(String userId);
1818

19-
@Query("SELECT new com.ODG.ODG_back.dto.participant.response.ParticipantListResponseDto(p.id, p.name, p.transportType, p.latitude, p.longitude, "
20-
+
21-
"CASE WHEN v.participant.id IS NOT NULL THEN true ELSE false END) " +
22-
"FROM Participant p LEFT JOIN Vote v ON p.id = v.participant.id " +
23-
"WHERE p.meeting.inviteCode = :linkCode")
19+
@Query("""
20+
SELECT new com.ODG.ODG_back.dto.participant.response.ParticipantListResponseDto(
21+
p.id,
22+
p.name,
23+
p.transportType,
24+
p.latitude,
25+
p.longitude,
26+
p.address,
27+
CASE WHEN COUNT(v.id) > 0 THEN true ELSE false END
28+
)
29+
FROM Participant p
30+
LEFT JOIN Vote v ON v.participant.id = p.id
31+
WHERE p.meeting.inviteCode = :linkCode
32+
GROUP BY p.id, p.name, p.transportType, p.latitude, p.longitude
33+
""")
2434
List<ParticipantListResponseDto> findParticipantsWithVoteStatus(
2535
@Param("linkCode") String linkCode);
2636
}

0 commit comments

Comments
 (0)