Skip to content

[Feat] 모의 서류 결과 삭제 API 구현#92

Merged
whc9999 merged 3 commits into
mainfrom
feat/#38-mock-apply-delete
May 28, 2026
Merged

[Feat] 모의 서류 결과 삭제 API 구현#92
whc9999 merged 3 commits into
mainfrom
feat/#38-mock-apply-delete

Conversation

@whc9999
Copy link
Copy Markdown
Collaborator

@whc9999 whc9999 commented May 28, 2026

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

  • DELETE /api/job-postings/{jobPostingId} 엔드포인트 추가
  • 로그인 사용자 소유 공고만 삭제 가능하도록 검증
  • 공고에 연결된 MockApply, 문항, 분석 결과, 문항 분석 결과 삭제
  • 공고별 MockApply sequence 카운터도 함께 정리
  • 공고 삭제 성공/권한 없음 테스트 추가

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [#38]

Summary by CodeRabbit

  • New Features

    • Authenticated delete endpoint: users can delete their own job postings.
    • Deleting a job posting now also removes all related mock interview data (applications, questions, analyses, and sequence records).
  • Tests

    • Added tests confirming full deletion cascade and that users cannot delete others’ job postings (forbidden).

Review Change Stack

- DELETE /api/job-postings/{jobPostingId} 엔드포인트 추가
- 로그인 사용자 소유 공고만 삭제 가능하도록 검증
- 공고에 연결된 MockApply, 문항, 분석 결과, 문항 분석 결과 삭제
- 공고별 MockApply sequence 카운터도 함께 정리
- 공고 삭제 성공/권한 없음 테스트 추가
@whc9999 whc9999 self-assigned this May 28, 2026
@whc9999 whc9999 added the ✨ feat New feature or request label May 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds authenticated DELETE /api/job-postings/{jobPostingId}, a transactional service method that validates ownership and cascades bulk deletions across question-analysis, question, analysis, mock-apply, mock-apply-sequence, and job posting repositories, plus repository delete methods and tests.

Changes

Job Posting Deletion Cascade

Layer / File(s) Summary
Repository deletion contracts
src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplySequenceRepository.java, src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/AnalysisRepository.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionRepository.java
Adds bulk-delete methods and required @Modifying/@Query annotations: deleteAllByUserIdAndJobPostingId, deleteAllByJobPostingId variants, and Modifying configuration on existing deletes.
Service deletion with cascade cleanup
src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingService.java
Wires new repository dependencies and implements deleteJobPosting(User user, Long jobPostingId) (transactional, audited) that validates ownership and performs ordered bulk deletions: question-analyses, questions, analyses, mock applies, mock-apply sequences, then deletes the job posting.
Controller delete endpoint
src/main/java/com/jobdri/jobdri_api/domain/jobposting/controller/JobPostingController.java
Adds @DeleteMapping import and exposes DELETE /api/job-postings/{jobPostingId} endpoint which validates the authenticated user, calls service deletion, and returns a success ApiResponse<Void>.
Deletion cascade test validation
src/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingServiceTest.java
Adds Spring tests verifying cascade deletion of related mock-apply and analysis/question entities and an authorization failure when deleting another user's job posting; includes helper methods for test data setup.

Sequence Diagram

sequenceDiagram
  participant Client
  participant JobPostingController
  participant JobPostingService
  participant QuestionAnalysisRepository
  participant QuestionRepository
  participant AnalysisRepository
  participant MockApplyRepository
  participant MockApplySequenceRepository
  participant JobPostingRepository

  Client->>JobPostingController: DELETE /api/job-postings/{jobPostingId}
  JobPostingController->>JobPostingService: deleteJobPosting(user, jobPostingId)
  Note over JobPostingService: validate ownership (getOwnedJobPosting)

  JobPostingService->>QuestionAnalysisRepository: deleteAllByJobPostingId(jobPostingId)
  JobPostingService->>QuestionRepository: deleteAllByJobPostingId(jobPostingId)
  JobPostingService->>AnalysisRepository: deleteAllByJobPostingId(jobPostingId)
  JobPostingService->>MockApplyRepository: deleteAllByJobPostingId(jobPostingId)
  JobPostingService->>MockApplySequenceRepository: deleteAllByUserIdAndJobPostingId(userId, jobPostingId)
  JobPostingService->>JobPostingRepository: deleteById(jobPostingId)

  JobPostingService-->>JobPostingController: void
  JobPostingController-->>Client: ApiResponse.success()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • JobDri-Developer/BackEnd#90: Changes around MockApplySequence keying (userId, jobPostingId), closely related to new deleteAllByUserIdAndJobPostingId usage.

Suggested reviewers

  • shinae1023

Poem

🐰 A posting's farewell, tidy and light,
Questions and analyses hop out of sight,
Sequences and mock applies take their leave—
Clean fields remain for new posts to weave. ✨

🚥 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 The title clearly describes the main change: implementing a DELETE API for mock document results (모의 서류 결과 삭제 API 구현), which aligns with the changeset that adds a job posting deletion endpoint and cascading deletion of related mock apply data.
Description check ✅ Passed The description follows the template structure with feature reason selected, detailed implementation details explaining the new endpoint and cascading deletions, confirmation of local testing and branch verification, and related issue reference provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#38-mock-apply-delete

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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
`@src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingService.java`:
- Around line 109-118: The current loop loads all MockApply entities via
mockApplyRepository.findAllByJobPostingId and issues per-row deletes
(analysisRepository.findByMockApplyId +
questionRepository.deleteAllByMockApplyId + analysisRepository.delete), causing
N+1 and large in-memory materialization; replace this with bulk delete
repository operations: add repository methods such as
mockApplyRepository.deleteAllByJobPostingId(jobPostingId) and/or
questionRepository.deleteAllByJobPostingId(jobPostingId),
analysisRepository.deleteAllByJobPostingId(jobPostingId) and
questionAnalysisRepository.deleteAllByJobPostingId(jobPostingId) (or implement
`@Modifying` JPQL/SQL queries using a subquery on MockApply ids) and invoke those
bulk deletes in the proper order (delete questionAnalysis -> question ->
analysis -> mockApply) to avoid loading individual MockApply/Analysis objects.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: aa11a110-5e8a-4f44-b906-bf4f1fa2bbe8

📥 Commits

Reviewing files that changed from the base of the PR and between fc22b46 and 4f5bd9b.

📒 Files selected for processing (4)
  • src/main/java/com/jobdri/jobdri_api/domain/jobposting/controller/JobPostingController.java
  • src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingService.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplySequenceRepository.java
  • src/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingServiceTest.java

채용 공고 삭제 시 연결 데이터를 bulk delete로 정리하도록 수정

MockApply 전체 로딩 후 루프 삭제하던 로직 제거
문항 분석, 문항, 분석, 모의 서류 지원 순서로 bulk delete 수행
공고별 MockApply sequence 카운터 정리 유지
삭제 API 테스트로 연결 데이터 정리 검증
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java (1)

17-26: 💤 Low value

Consider simplifying the query for consistency.

The subquery approach works correctly but could be simplified to use direct property path navigation like the other repositories:

`@Query`("""
        delete from QuestionAnalysis qa
        where qa.analysis.mockApply.jobPosting.id = :jobPostingId
        """)

This would be more consistent with AnalysisRepository and QuestionRepository, which use direct path navigation.

🤖 Prompt for 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.

In
`@src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java`
around lines 17 - 26, The method deleteAllByJobPostingId in
QuestionAnalysisRepository uses a subquery; simplify it by changing the JPQL to
use direct path navigation (navigate through
qa.analysis.mockApply.jobPosting.id) similar to AnalysisRepository and
QuestionRepository so the delete directly targets QuestionAnalysis entities by
qa.analysis.mockApply.jobPosting.id = :jobPostingId and keep the existing
`@Modifying` and `@Param` annotations and method signature intact.
🤖 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
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java`:
- Around line 17-18: The derived delete method deleteAllByJobPostingId in
MockApplyRepository should use an explicit bulk JPQL DELETE to avoid entity
loading; update MockApplyRepository by adding a `@Query` annotation with a JPQL
statement like "DELETE FROM MockApply m WHERE m.jobPosting.id = :jobPostingId"
(keep the existing `@Modifying`(clearAutomatically = true, flushAutomatically =
true) and bind the parameter name jobPostingId) so the repository executes a
single bulk DELETE rather than removing entities one-by-one.

---

Nitpick comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java`:
- Around line 17-26: The method deleteAllByJobPostingId in
QuestionAnalysisRepository uses a subquery; simplify it by changing the JPQL to
use direct path navigation (navigate through
qa.analysis.mockApply.jobPosting.id) similar to AnalysisRepository and
QuestionRepository so the delete directly targets QuestionAnalysis entities by
qa.analysis.mockApply.jobPosting.id = :jobPostingId and keep the existing
`@Modifying` and `@Param` annotations and method signature intact.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b2b2ba35-a5c6-465c-8da4-109094cae002

📥 Commits

Reviewing files that changed from the base of the PR and between 4f5bd9b and 2acf917.

📒 Files selected for processing (5)
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/AnalysisRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingService.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingService.java

MockApply 삭제 시 파생 delete 메서드 대신 JPQL bulk delete를 사용하도록 수정

MockApplyRepository.deleteAllByJobPostingId에 @query delete문 추가
공고 삭제 시 MockApply 엔티티 로딩 없이 일괄 삭제되도록 개선
기존 삭제 API 동작 검증 유지
@whc9999 whc9999 merged commit 9b76425 into main May 28, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant