From ac7fcbd2fe9ccf31cf0d87599fa7f56ec9eccbc0 Mon Sep 17 00:00:00 2001 From: jhbkjh Date: Thu, 30 Oct 2025 16:21:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?api=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95(?= =?UTF-8?q?participation)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DebugController.java | 104 ------------------ .../controller/ParticipationController.java | 12 +- .../controller/WinnerController.java | 8 +- 3 files changed, 10 insertions(+), 114 deletions(-) delete mode 100644 participation-service/src/main/java/com/kt/event/participation/presentation/controller/DebugController.java diff --git a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/DebugController.java b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/DebugController.java deleted file mode 100644 index a186d0f..0000000 --- a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/DebugController.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.kt.event.participation.presentation.controller; - -import com.kt.event.participation.domain.participant.Participant; -import com.kt.event.participation.domain.participant.ParticipantRepository; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 디버깅용 컨트롤러 - */ -@Slf4j -@CrossOrigin(origins = "http://localhost:3000") -@RestController -@RequestMapping("/debug") -@RequiredArgsConstructor -public class DebugController { - - private final ParticipantRepository participantRepository; - - /** - * 중복 참여 체크 테스트 - */ - @GetMapping("/exists/{eventId}/{phoneNumber}") - public String testExists(@PathVariable String eventId, @PathVariable String phoneNumber) { - try { - log.info("디버그: 중복 체크 시작 - eventId: {}, phoneNumber: {}", eventId, phoneNumber); - - boolean exists = participantRepository.existsByEventIdAndPhoneNumber(eventId, phoneNumber); - - log.info("디버그: 중복 체크 결과 - exists: {}", exists); - - long totalCount = participantRepository.count(); - long eventCount = participantRepository.countByEventId(eventId); - - return String.format( - "eventId: %s, phoneNumber: %s, exists: %s, totalCount: %d, eventCount: %d", - eventId, phoneNumber, exists, totalCount, eventCount - ); - - } catch (Exception e) { - log.error("디버그: 예외 발생", e); - return "ERROR: " + e.getMessage(); - } - } - - /** - * 모든 참여자 데이터 조회 - */ - @GetMapping("/participants") - public String getAllParticipants() { - try { - List participants = participantRepository.findAll(); - - StringBuilder sb = new StringBuilder(); - sb.append("Total participants: ").append(participants.size()).append("\n\n"); - - for (Participant p : participants) { - sb.append(String.format("ID: %s, EventID: %s, Phone: %s, Name: %s\n", - p.getParticipantId(), p.getEventId(), p.getPhoneNumber(), p.getName())); - } - - return sb.toString(); - - } catch (Exception e) { - log.error("디버그: 참여자 조회 예외 발생", e); - return "ERROR: " + e.getMessage(); - } - } - - /** - * 특정 전화번호의 참여 이력 조회 - */ - @GetMapping("/phone/{phoneNumber}") - public String getByPhoneNumber(@PathVariable String phoneNumber) { - try { - List participants = participantRepository.findAll(); - - StringBuilder sb = new StringBuilder(); - sb.append("Participants with phone: ").append(phoneNumber).append("\n\n"); - - int count = 0; - for (Participant p : participants) { - if (phoneNumber.equals(p.getPhoneNumber())) { - sb.append(String.format("ID: %s, EventID: %s, Name: %s\n", - p.getParticipantId(), p.getEventId(), p.getName())); - count++; - } - } - - if (count == 0) { - sb.append("No participants found with this phone number."); - } - - return sb.toString(); - - } catch (Exception e) { - log.error("디버그: 전화번호별 조회 예외 발생", e); - return "ERROR: " + e.getMessage(); - } - } -} \ No newline at end of file diff --git a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java index 078f913..d6c01a7 100644 --- a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java +++ b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java @@ -35,9 +35,9 @@ public class ParticipationController { /** * 이벤트 참여 - * POST /events/{eventId}/participate + * POST /participations/{eventId}/participate */ - @PostMapping("/events/{eventId}/participate") + @PostMapping("/participations/{eventId}/participate") public ResponseEntity> participate( @PathVariable String eventId, @Valid @RequestBody ParticipationRequest request) { @@ -61,14 +61,14 @@ public class ParticipationController { /** * 참여자 목록 조회 - * GET /events/{eventId}/participants + * GET /participations/{eventId}/participants */ @Operation( summary = "참여자 목록 조회", description = "이벤트의 참여자 목록을 페이징하여 조회합니다. " + "정렬 가능한 필드: createdAt(기본값), participantId, name, phoneNumber, bonusEntries, isWinner, wonAt" ) - @GetMapping("/events/{eventId}/participants") + @GetMapping("/participations/{eventId}/participants") public ResponseEntity>> getParticipants( @Parameter(description = "이벤트 ID", example = "evt_20250124_001") @PathVariable String eventId, @@ -89,9 +89,9 @@ public class ParticipationController { /** * 참여자 상세 조회 - * GET /events/{eventId}/participants/{participantId} + * GET /participations/{eventId}/participants/{participantId} */ - @GetMapping("/events/{eventId}/participants/{participantId}") + @GetMapping("/participations/{eventId}/participants/{participantId}") public ResponseEntity> getParticipant( @PathVariable String eventId, @PathVariable String participantId) { diff --git a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/WinnerController.java b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/WinnerController.java index 3adf1fe..4a42e61 100644 --- a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/WinnerController.java +++ b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/WinnerController.java @@ -35,9 +35,9 @@ public class WinnerController { /** * 당첨자 추첨 - * POST /events/{eventId}/draw-winners + * POST /participations/{eventId}/draw-winners */ - @PostMapping("/events/{eventId}/draw-winners") + @PostMapping("/participations/{eventId}/draw-winners") public ResponseEntity> drawWinners( @PathVariable String eventId, @Valid @RequestBody DrawWinnersRequest request) { @@ -50,14 +50,14 @@ public class WinnerController { /** * 당첨자 목록 조회 - * GET /events/{eventId}/winners + * GET /participations/{eventId}/winners */ @Operation( summary = "당첨자 목록 조회", description = "이벤트의 당첨자 목록을 페이징하여 조회합니다. " + "정렬 가능한 필드: winnerRank(기본값), wonAt, participantId, name, phoneNumber, bonusEntries" ) - @GetMapping("/events/{eventId}/winners") + @GetMapping("/participations/{eventId}/winners") public ResponseEntity>> getWinners( @Parameter(description = "이벤트 ID", example = "evt_20250124_001") @PathVariable String eventId, From 52b63fb0f0c5e58e16a17e252d967a156542a578 Mon Sep 17 00:00:00 2001 From: jhbkjh Date: Thu, 30 Oct 2025 16:49:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?frontend=20=EC=97=B0=EB=8F=99=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20=EC=9E=84=EC=8B=9C=20=EC=BB=A4=EB=B0=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/controller/ParticipationController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java index d6c01a7..39f8b58 100644 --- a/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java +++ b/participation-service/src/main/java/com/kt/event/participation/presentation/controller/ParticipationController.java @@ -62,13 +62,14 @@ public class ParticipationController { /** * 참여자 목록 조회 * GET /participations/{eventId}/participants + * GET /events/{eventId}/participants (프론트엔드 호환) */ @Operation( summary = "참여자 목록 조회", description = "이벤트의 참여자 목록을 페이징하여 조회합니다. " + "정렬 가능한 필드: createdAt(기본값), participantId, name, phoneNumber, bonusEntries, isWinner, wonAt" ) - @GetMapping("/participations/{eventId}/participants") + @GetMapping({"/participations/{eventId}/participants", "/events/{eventId}/participants"}) public ResponseEntity>> getParticipants( @Parameter(description = "이벤트 ID", example = "evt_20250124_001") @PathVariable String eventId, @@ -90,8 +91,9 @@ public class ParticipationController { /** * 참여자 상세 조회 * GET /participations/{eventId}/participants/{participantId} + * GET /events/{eventId}/participants/{participantId} (프론트엔드 호환) */ - @GetMapping("/participations/{eventId}/participants/{participantId}") + @GetMapping({"/participations/{eventId}/participants/{participantId}", "/events/{eventId}/participants/{participantId}"}) public ResponseEntity> getParticipant( @PathVariable String eventId, @PathVariable String participantId) {