Feat : 설문조사 조회 및 참여 기능 추가#87
Conversation
- 활성 설문조사 조회 API 추가 - 설문조사 참여 가능 여부 조회 API 추가 - 설문조사 참여 기록 저장 API 추가 - 참여 가능 조건으로 운동 기록 수 2, 6, 10회 및 미참여 여부 검증 - 설문 참여 저장 시 활성 설문 여부와 참여 대상 여부 재검증 - 사용자별 설문 중복 참여 방지를 위한 unique 제약 추가
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a complete survey feature module with REST endpoints, JPA entities for surveys and user participation tracking, repositories for data access, a service layer implementing eligibility checks based on workout counts, and new error codes for survey-related failures. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller as SurveyController
participant Service as SurveyService
participant Repos as Repositories
participant WS as WorkoutService
participant DB as Database
Client->>Controller: POST /api/v1/survey/{surveyId}/participate
Controller->>Service: participateSurvey(surveyId)
Service->>Repos: JwtUtil.getUser()
Repos-->>Service: User
Service->>Repos: SurveyRepository.findByIdAndActiveTrue(surveyId)
Repos->>DB: Query active survey by ID
DB-->>Repos: Survey (if exists)
Repos-->>Service: Optional<Survey>
Service->>Repos: UserSurveyParticipationRepository.existsByUserAndSurvey(user, survey)
Repos->>DB: Check participation exists
DB-->>Repos: boolean
Repos-->>Service: Already participated?
alt Already Participated
Service-->>Controller: Throw CustomException(SURVEY_ALREADY_RESPONDED)
else Not Participated
Service->>WS: countUserWorkouts(user)
WS->>DB: Count user workouts
DB-->>WS: count
WS-->>Service: long
Service->>Service: isEligibleWorkoutCount(user)
alt Not Eligible (count ≠ 2, 6, 10)
Service-->>Controller: Throw CustomException(SURVEY_NOT_ELIGIBLE)
else Eligible
Service->>Repos: UserSurveyParticipationRepository.save(participation)
Repos->>DB: Insert participation record
DB-->>Repos: Persisted
Repos-->>Service: Done
Service-->>Controller: Success (Void)
Controller-->>Client: ApiResponse<Void> 200 OK
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎯 작업 내용
📝 상세 설명
활성화된 설문조사를 조회하고, 사용자의 설문조사 참여 가능 여부를 확인한 뒤 참여 이력을 저장할 수 있도록 구현했습니다.
user_id,survey_idunique 제약 추가✅ 테스트
Summary by CodeRabbit