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..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 @@ -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,15 @@ public class ParticipationController { /** * 참여자 목록 조회 - * GET /events/{eventId}/participants + * GET /participations/{eventId}/participants + * GET /events/{eventId}/participants (프론트엔드 호환) */ @Operation( summary = "참여자 목록 조회", description = "이벤트의 참여자 목록을 페이징하여 조회합니다. " + "정렬 가능한 필드: createdAt(기본값), participantId, name, phoneNumber, bonusEntries, isWinner, wonAt" ) - @GetMapping("/events/{eventId}/participants") + @GetMapping({"/participations/{eventId}/participants", "/events/{eventId}/participants"}) public ResponseEntity>> getParticipants( @Parameter(description = "이벤트 ID", example = "evt_20250124_001") @PathVariable String eventId, @@ -89,9 +90,10 @@ public class ParticipationController { /** * 참여자 상세 조회 - * GET /events/{eventId}/participants/{participantId} + * GET /participations/{eventId}/participants/{participantId} + * GET /events/{eventId}/participants/{participantId} (프론트엔드 호환) */ - @GetMapping("/events/{eventId}/participants/{participantId}") + @GetMapping({"/participations/{eventId}/participants/{participantId}", "/events/{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,