Skip to content

Comments

feat : 크루 참여 요청 시 질문 답변 기능 구현#50

Open
ekfrehd wants to merge 1 commit intodevelopfrom
feature-49/answer-recruitment-question
Open

feat : 크루 참여 요청 시 질문 답변 기능 구현#50
ekfrehd wants to merge 1 commit intodevelopfrom
feature-49/answer-recruitment-question

Conversation

@ekfrehd
Copy link
Contributor

@ekfrehd ekfrehd commented Aug 10, 2025

  • RecruitmentAnswer 엔티티 추가, 참여 요청 시 답변 저장
  • 참여 요청자 본인의 지원 현황(답변 포함) 조회 기능 구현
  • PENDING 상태의 참여 요청에 대한 답변 수정 기능 구현
  • 답변 개수 불일치, 타 크루 질문 등 유효성 검증 로직 및 테스트 코드 추가

🔍 PR 타입 선택

아래 타입 중 해당하는 하나를 선택해 주세요. 반드시 하나만 선택해 주세요.

  • feat: 새로운 기능 추가
  • fix: 버그 수정
  • docs: 문서 수정
  • style: 코드 포맷팅, 세미콜론 누락, 코드 변경이 없는 경우
  • refactor: 코드 리팩토링
  • test: 테스트 코드 추가 또는 수정
  • chore: 빌드 업무 수정, 패키지 매니저 수정 등 기타 작업

📝 변경 사항 요약

  • RecruitmentAnswer 엔티티 추가: 참여 요청(Demand)에 대한 개별 답변 저장을 위한 RecruitmentAnswer 엔티티 및 RecruitmentAnswerContent VO 추가
  • 참여 요청 시 답변 제출 기능: POST /crews/{crewId}/demands API를 통해 답변 목록을 함께 제출하고 저장하는 로직 구현
  • 내 참여 요청 조회 기능: GET /crews/{crewId}/demands/my-demand API를 통해 본인의 요청 상태 및 제출 답변 조회 기능 추가
  • 참여 요청 수정 기능: PENDING 상태의 참여 요청에 한해, 본인 답변을 수정하는 PUT /crews/{crewId}/demands/my-demand API 추가
  • 유효성 검증 강화: 답변 개수 불일치, 다른 크루 질문에 대한 답변 등 비정상적 요청에 대한 서버 측 유효성 검증 로직 추가
  • 테스트 코드 작성: 신규 기능에 대한 단위/통합 테스트 코드 작성 및 보강

🛠 관련 이슈

Resolves: #49
Ref:
Related to:
close: #번호

추가 설명 (선택 사항)

  • 참여 요청 수정은 PENDING 상태에서만 가능하도록 제한하여 데이터 정합성 보장.
  • Demand 애그리거트가 RecruitmentAnswer의 생명주기를 관리하도록 설계하여 DDD 원칙 준수.

- RecruitmentAnswer 엔티티 추가, 참여 요청 시 답변 저장
- 참여 요청자 본인의 지원 현황(답변 포함) 조회 기능 구현
- PENDING 상태의 참여 요청에 대한 답변 수정 기능 구현
- 답변 개수 불일치, 타 크루 질문 등 유효성 검증 로직 및 테스트 코드 추가
Copy link
Contributor

@mandykr mandykr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 👏

return ApiResponse.ok(response);
}

@GetMapping("/{crewId}/demands/my-demand")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uri "/{crewId}/demands/me" 제안드립니다

Comment on lines +71 to +73
if (crew.getRecruitment().getRecruitmentQuestions().getValues().size() != request.answers().size()) {
throw new InvalidValueException(ErrorCode.MISMATCHED_ANSWER_COUNT);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디미터 법칙을 참고해 주시면 좋을것 같아요

Comment on lines +77 to +83
request.answers().forEach(answerRequest -> {
RecruitmentQuestion question = recruitmentQuestionRepository.findById(answerRequest.questionId())
.orElseThrow(QuestionNotFoundException::new);

if (!question.getCrew().getId().equals(crewId)) {
throw new InvalidValueException(ErrorCode.INVALID_QUESTION_FOR_CREW);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jpa 쓰기 지연이 작동하겠지만 반복문으로 repository 를 호출하는건 문제가 될 수 있어 보입니다. 한번에 목록으로 조회해서 적절한 책임을 갖는 객체에서 검증하는 것도 괜찮을것 같아요.

Comment on lines +197 to +201
List<RecruitmentAnswer> newAnswers = request.answers().stream()
.map(answerRequest -> {
RecruitmentQuestion question = findRecruitmentQuestionByIdAndCrewId(answerRequest.questionId(), crewId);
return RecruitmentAnswer.of(demand, question, answerRequest.content());
}).toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리스트를 다루는 로직은 아무래도 일급컬렉션을 사용하는게 깔끔해 보입니다.

Comment on lines +18 to +23
public static UpdateDemandResponse from(Demand demand) {
return UpdateDemandResponse.builder()
.crewId(demand.getCrew().getId())
.demandId(demand.getId())
.build();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드명 of 로 통일하는게 좋겠어요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

사용자 크루 참여 요청시 답변 작성

2 participants