Merge pull request #32 from ktds-dg0501/feature/partici2

Feature/partici2
This commit is contained in:
kkkd-max 2025-10-30 17:01:19 +09:00 committed by GitHub
commit f2e8f7499f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 114 deletions

View File

@ -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<Participant> 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<Participant> 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();
}
}
}

View File

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

View File

@ -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<ApiResponse<DrawWinnersResponse>> drawWinners( public ResponseEntity<ApiResponse<DrawWinnersResponse>> drawWinners(
@PathVariable String eventId, @PathVariable String eventId,
@Valid @RequestBody DrawWinnersRequest request) { @Valid @RequestBody DrawWinnersRequest request) {
@ -50,14 +50,14 @@ public class WinnerController {
/** /**
* 당첨자 목록 조회 * 당첨자 목록 조회
* GET /events/{eventId}/winners * GET /participations/{eventId}/winners
*/ */
@Operation( @Operation(
summary = "당첨자 목록 조회", summary = "당첨자 목록 조회",
description = "이벤트의 당첨자 목록을 페이징하여 조회합니다. " + description = "이벤트의 당첨자 목록을 페이징하여 조회합니다. " +
"정렬 가능한 필드: winnerRank(기본값), wonAt, participantId, name, phoneNumber, bonusEntries" "정렬 가능한 필드: winnerRank(기본값), wonAt, participantId, name, phoneNumber, bonusEntries"
) )
@GetMapping("/events/{eventId}/winners") @GetMapping("/participations/{eventId}/winners")
public ResponseEntity<ApiResponse<PageResponse<ParticipationResponse>>> getWinners( public ResponseEntity<ApiResponse<PageResponse<ParticipationResponse>>> getWinners(
@Parameter(description = "이벤트 ID", example = "evt_20250124_001") @Parameter(description = "이벤트 ID", example = "evt_20250124_001")
@PathVariable String eventId, @PathVariable String eventId,