Skip to content

[✨Feat] 자기소개서 문항 저장 API 구현#37

Merged
yong203 merged 1 commit into
devfrom
feat/#36
Jun 19, 2026
Merged

[✨Feat] 자기소개서 문항 저장 API 구현#37
yong203 merged 1 commit into
devfrom
feat/#36

Conversation

@yong203

@yong203 yong203 commented Jun 19, 2026

Copy link
Copy Markdown
Member

작업 내용

  • PUT /cover-letters/{coverLetterId}/questions API를 추가했습니다.
  • cover_letter_questions JPA entity/repository를 추가해 등록 step3 문항과 원본 답변을 저장합니다.
  • 현재 사용자 소유의 삭제되지 않은 DRAFT 자기소개서만 수정 가능하도록 service 정책을 적용했습니다.
  • 요청 questions 배열을 전체 replace 방식으로 저장하고, 서버가 order를 1부터 재부여하도록 구현했습니다.
  • question, maxAnswerLength, originalAnswer validation과 field별 details 응답을 추가했습니다.
  • controller/service/repository 테스트로 성공, replace, validation 실패, NOT_FOUND, COVER_LETTER_NOT_DRAFT 케이스를 검증했습니다.

스크린샷

1. test 전 coverLetter db 확인_스크린샷에 표시한 coverLetterId로 question 생성 api test 진행

<img width="1221" height="241" alt="스크린샷 2026-06-19 오후 6 54 35" src="https://github.com/user-attachments/assets/ab1f4
스크린샷 2026-06-19 오후 7 06 00
cc8-3ef0-4f9f-b7f9-543439a334c3" />

2. @PutMapping("/cover-letters/{coverLetterId}/questions") api 요청 진행

maxAnswerLength 은 100 이상이어야 정상 처리됨
스크린샷 2026-06-19 오후 7 15 45

3. @PutMapping("/cover-letters/{coverLetterId}/questions") api 요청 진행

스크린샷 2026-06-19 오후 7 16 04

4. cover_letter_questions table 확인

스크린샷 2026-06-19 오후 7 16 18

관련 이슈

문서 반영

  • 반영한 문서:
    • docs/api/README.md
    • docs/api/cover-letters.md
    • docs/status.md

확인 결과

  • git diff --check
  • ./gradlew test
  • ./gradlew check
  • 기타:
  • 실행하지 못함. 이유:

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 자기소개서 문항 저장 기능 추가 - PUT 엔드포인트를 통해 문항과 답변을 저장 및 검증할 수 있습니다.
  • Documentation

    • API 문서에 검증 실패 및 상태 충돌 시나리오에 대한 오류 응답 예시 추가.
  • Tests

    • 문항 저장 API, 데이터 접근, 비즈니스 로직에 대한 포괄적인 테스트 케이스 추가.
  • Chores

    • 기능 로드맵 및 API 상태 추적 문서 업데이트.

@yong203 yong203 linked an issue Jun 19, 2026 that may be closed by this pull request
7 tasks
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

PUT /cover-letters/{coverLetterId}/questions 엔드포인트(API-011)를 신규 구현한다. CoverLetterQuestion JPA 엔티티 및 리포지토리, CoverLetterService.saveQuestions 트랜잭션 메서드(DRAFT 검증·전체 replace·updatedAt 갱신), 컨트롤러 엔드포인트, 관련 DTO, 테스트, API 문서를 추가한다.

Changes

자기소개서 질문 저장 API(API-011) 전체 구현

Layer / File(s) Summary
CoverLetterQuestion 엔티티·리포지토리 및 CoverLetter.touch()
src/main/java/com/daon/rewrite/coverletter/entity/CoverLetterQuestion.java, src/main/java/com/daon/rewrite/coverletter/repository/CoverLetterQuestionRepository.java, src/main/java/com/daon/rewrite/coverletter/entity/CoverLetter.java
cover_letter_questions 테이블 매핑 JPA 엔티티와 정렬 조회·삭제 리포지토리 인터페이스를 추가한다. CoverLetterupdatedAt을 갱신하는 touch(Instant) 메서드를 추가한다.
서비스 입출력 타입 및 컨트롤러 DTO
src/main/java/com/daon/rewrite/coverletter/service/SaveQuestionInput.java, src/main/java/com/daon/rewrite/coverletter/service/SaveQuestionsResult.java, src/main/java/com/daon/rewrite/coverletter/dto/SaveQuestionsRequest.java, src/main/java/com/daon/rewrite/coverletter/dto/SaveQuestionsResponse.java
SaveQuestionInput(서비스 입력), SaveQuestionsResult(서비스 반환), SaveQuestionsRequest(요청 DTO·toInputs() 변환), SaveQuestionsResponse(응답 DTO·from() 팩토리, Asia/Seoul 타임존 변환) record를 추가한다.
CoverLetterService.saveQuestions 및 검증 로직
src/main/java/com/daon/rewrite/coverletter/service/CoverLetterService.java
saveQuestions 트랜잭션 메서드를 추가한다. DRAFT 상태 확인 후 validateAndNormalizeQuestions로 null·빈 목록·항목별 필드·maxAnswerLength 범위(100~5000)를 인덱스 기반 details로 누적 검증하고, 기존 문항 전체 삭제 후 새 문항 일괄 저장, touch()로 갱신 시각을 반영한다.
컨트롤러 엔드포인트
src/main/java/com/daon/rewrite/coverletter/controller/CoverLetterController.java
PUT /cover-letters/{coverLetterId}/questions 엔드포인트를 추가한다. 요청의 toInputs() 결과를 서비스에 전달하고 SaveQuestionsResponse.from()으로 응답을 생성한다.
리포지토리·서비스·컨트롤러 테스트
src/test/java/com/daon/rewrite/coverletter/repository/CoverLetterQuestionRepositoryTest.java, src/test/java/com/daon/rewrite/coverletter/service/CoverLetterServiceTest.java, src/test/java/com/daon/rewrite/coverletter/controller/CoverLetterControllerTest.java
리포지토리 JPA 통합 테스트(정렬 조회·삭제 격리), 서비스 통합 테스트(성공·NOT_FOUND·COVER_LETTER_NOT_DRAFT·VALIDATION_ERROR·빈 목록), 컨트롤러 슬라이스 테스트(성공·검증 오류·미존재·비 DRAFT)를 추가한다.
API 문서 및 상태 추적 갱신
docs/api/cover-letters.md, docs/api/README.md, docs/status.md
cover-letters.mdVALIDATION_ERROR·COVER_LETTER_NOT_DRAFT 오류 응답 예시를 추가하고, README.md의 API-011 상태를 Implemented로, status.md의 REQ-004를 Implemented로 갱신하며 REQ-005 신규 후보를 추가한다.

Possibly related issues

  • #36 [✨Feat] 자기소개서 문항 저장 API 구현: 이 PR은 해당 이슈에서 정의한 PUT /cover-letters/{coverLetterId}/questions API(API-011, REQ-004)의 모든 완료 기준(엔티티·리포지토리·서비스 검증·replace 저장·updatedAt 갱신·테스트·문서)을 직접 구현한다.

Possibly related PRs

  • Rewrite-Team/Rewrite-BE#19: CoverLetter 엔티티와 CoverLetterService를 공유하며, 초안 생성(POST /cover-letters) 기반 위에 이 PR의 질문 저장 흐름이 동작한다.
  • Rewrite-Team/Rewrite-BE#27: CoverLetter JPA 모델과 Instant 기반 타임스탬프 설계를 공유하며, 이 PR의 touch(Instant) 메서드가 동일 필드를 갱신한다.
  • Rewrite-Team/Rewrite-BE#33: BusinessException의 details 구조 및 COVER_LETTER_NOT_DRAFT 에러 코드가 이 PR의 검증 오류 응답에 직접 사용된다.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목 '[✨Feat] 자기소개서 문항 저장 API 구현'은 변경사항의 주요 내용인 PUT /cover-letters/{coverLetterId}/questions API 구현을 명확하고 간결하게 설명합니다.
Description check ✅ Passed PR 설명은 템플릿의 '작업 내용', '관련 이슈', '문서 반영' 섹션을 완벽하게 포함하며, 구체적인 구현 내용과 스크린샷을 통한 검증 결과를 제시합니다.
Linked Issues check ✅ Passed PR은 #36의 모든 핵심 요구사항을 충족합니다: API 엔드포인트 구현, entity/repository 추가, DRAFT 검증, replace 방식 저장, 필드별 validation, 테스트 추가, 문서 갱신 등이 raw_summary에서 확인됩니다.
Out of Scope Changes check ✅ Passed 모든 변경사항은 #36의 작업 범위 내에 있습니다. API-011 구현, cover_letter_questions entity/repository, validation, 테스트, 문서 업데이트만 포함되어 있으며 제외 항목(API-012, API-014 등)은 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@yong203 yong203 self-assigned this Jun 19, 2026
@yong203 yong203 added the ✨ Feature 새로운 기능 구현 label Jun 19, 2026
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.63636% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ewrite/coverletter/service/CoverLetterService.java 86.66% 2 Missing and 4 partials ⚠️
.../rewrite/coverletter/dto/SaveQuestionsRequest.java 66.66% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@yong203 yong203 marked this pull request as ready for review June 19, 2026 10:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/api/cover-letters.md`:
- Around line 294-295: The VALIDATION_ERROR message example in the documentation
at line 294 shows "요청 값이 올바르지 않습니다." but this does not match the actual response
message from the implementation which is "입력값이 올바르지 않습니다." according to the PR
description. Update the message field value in the VALIDATION_ERROR example to
use "입력값이 올바르지 않습니다." instead to ensure consistency between the documentation
and the actual implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9e117fbd-6e3c-40aa-a8cc-2cef5060900e

📥 Commits

Reviewing files that changed from the base of the PR and between db77097 and c6a0865.

📒 Files selected for processing (15)
  • docs/api/README.md
  • docs/api/cover-letters.md
  • docs/status.md
  • src/main/java/com/daon/rewrite/coverletter/controller/CoverLetterController.java
  • src/main/java/com/daon/rewrite/coverletter/dto/SaveQuestionsRequest.java
  • src/main/java/com/daon/rewrite/coverletter/dto/SaveQuestionsResponse.java
  • src/main/java/com/daon/rewrite/coverletter/entity/CoverLetter.java
  • src/main/java/com/daon/rewrite/coverletter/entity/CoverLetterQuestion.java
  • src/main/java/com/daon/rewrite/coverletter/repository/CoverLetterQuestionRepository.java
  • src/main/java/com/daon/rewrite/coverletter/service/CoverLetterService.java
  • src/main/java/com/daon/rewrite/coverletter/service/SaveQuestionInput.java
  • src/main/java/com/daon/rewrite/coverletter/service/SaveQuestionsResult.java
  • src/test/java/com/daon/rewrite/coverletter/controller/CoverLetterControllerTest.java
  • src/test/java/com/daon/rewrite/coverletter/repository/CoverLetterQuestionRepositoryTest.java
  • src/test/java/com/daon/rewrite/coverletter/service/CoverLetterServiceTest.java

Comment thread docs/api/cover-letters.md
@yong203 yong203 merged commit 2199b43 into dev Jun 19, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[✨Feat] 자기소개서 문항 저장 API 구현

1 participant