Skip to content

[Fix] 모의 지원 단건 삭제 로직 추가#129

Merged
whc9999 merged 2 commits into
devfrom
fix/delete-mock-apply-by-id
Jul 17, 2026
Merged

[Fix] 모의 지원 단건 삭제 로직 추가#129
whc9999 merged 2 commits into
devfrom
fix/delete-mock-apply-by-id

Conversation

@whc9999

@whc9999 whc9999 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

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

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

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

  • DELETE /api/mock-applies/{mockApplyId} 추가
  • 모의 지원 단건 기준으로 QuestionAnalysis -> Analysis -> Question -> MockApply 순서 삭제 같은 공고에 연결된 다른 모의 지원/문항/분석은 유지
  • 다른 사용자의 모의 지원 삭제 시 FORBIDDEN 유지
  • 단건 삭제 회귀 테스트 추가

📸 작업 화면 스크린샷

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

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

🚨 관련 이슈 번호 [ ]

Summary by CodeRabbit

  • New Features

    • Added the ability to delete an individual mock application.
    • Deletion also removes its associated questions and analysis data while preserving unrelated records.
    • Added access controls to prevent deleting mock applications owned by another user.
  • Bug Fixes

    • Improved cleanup of related data when a mock application is deleted.
  • Tests

    • Added coverage for successful deletion, data preservation, and authorization failures.

DELETE /api/mock-applies/{mockApplyId} 추가
모의 지원 단건 기준으로 QuestionAnalysis -> Analysis -> Question -> MockApply 순서 삭제
같은 공고에 연결된 다른 모의 지원/문항/분석은 유지
다른 사용자의 모의 지원 삭제 시 FORBIDDEN 유지
단건 삭제 회귀 테스트 추가
@whc9999 whc9999 self-assigned this Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@whc9999, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6373a396-94ea-4d22-85bb-9c76114a4e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 6973972 and 00ba5de.

📒 Files selected for processing (2)
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
📝 Walkthrough

Walkthrough

Adds mock-application deletion through repository bulk-delete queries, transactional service orchestration, a secured HTTP DELETE endpoint, and tests for cascading data removal and ownership enforcement.

Changes

Mock application deletion

Layer / File(s) Summary
Bulk deletion repositories
src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/..., src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
Adds JPQL bulk-delete methods for analysis, question-analysis, and mock-apply records by mock-apply ID.
Transactional deletion orchestration
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
Validates the requester and ownership, then deletes related question-analysis, analysis, question, and mock-apply records within a transaction.
DELETE endpoint and validation
src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java, src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java
Exposes DELETE /{mockApplyId} and tests related-record removal, preservation of unrelated data, and forbidden access.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: ✨ feat

Suggested reviewers: shinae1023

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 모의 지원 단건 삭제 로직 추가라는 핵심 변경을 명확히 요약합니다.
Description check ✅ Passed 템플릿의 주요 섹션과 체크리스트를 대부분 채웠고, 작업 내용과 의도가 구체적으로 적혀 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/delete-mock-apply-by-id

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.

❤️ Share

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

@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.

🧹 Nitpick comments (2)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java (1)

53-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding @ApiResponses documentation.

Other endpoints in this controller document their success and standard HTTP error codes (401, 403, 404) via @ApiResponses. Adding them here would maintain Swagger documentation consistency.

📝 Proposed OpenAPI annotations
     `@Operation`(
             summary = "모의 서류 지원 단건 삭제",
             description = "mockApplyId에 해당하는 모의 서류 지원과 연결된 문항, 분석 결과만 삭제합니다. 같은 공고의 다른 모의 지원은 유지됩니다."
     )
+    `@ApiResponses`(value = {
+            `@io.swagger.v3.oas.annotations.responses.ApiResponse`(
+                    responseCode = "200",
+                    description = "모의 서류 지원 단건 삭제 성공"
+            ),
+            `@io.swagger.v3.oas.annotations.responses.ApiResponse`(
+                    responseCode = "401",
+                    description = "인증 정보 누락"
+            ),
+            `@io.swagger.v3.oas.annotations.responses.ApiResponse`(
+                    responseCode = "403",
+                    description = "다른 사용자의 모의 서류 지원 접근 시도"
+            ),
+            `@io.swagger.v3.oas.annotations.responses.ApiResponse`(
+                    responseCode = "404",
+                    description = "해당 모의 서류 지원 없음"
+            )
+    })
     `@DeleteMapping`("/{mockApplyId}")
🤖 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/mockapply/controller/MockApplyController.java`
around lines 53 - 57, Update the delete endpoint method associated with
`@DeleteMapping`("/{mockApplyId}") in MockApplyController by adding `@ApiResponses`
documentation for the successful deletion response and standard 401, 403, and
404 error responses, matching the annotation style used by the other controller
endpoints.
src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java (1)

17-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer explicit subqueries over implicit joins in JPQL DELETE.

Traversing multiple relationship levels (e.g., qa.analysis.mockApply.id) in a JPQL DELETE query relies on the JPA provider (Hibernate 6) to dynamically generate subqueries, as standard SQL/JPA does not support joins in DELETE statements.

To ensure safety and maintain consistency with the explicit subquery pattern already used in deleteAllByJobPostingId (lines 28-32), consider rewriting this query with explicit subqueries.

♻️ Proposed refactor
     `@Modifying`(clearAutomatically = true, flushAutomatically = true)
     `@Query`("""
             delete from QuestionAnalysis qa
-            where qa.analysis.mockApply.id = :mockApplyId
-               or qa.question.mockApply.id = :mockApplyId
+            where qa.analysis.id in (
+                select a.id
+                from Analysis a
+                where a.mockApply.id = :mockApplyId
+            )
+               or qa.question.id in (
+                select q.id
+                from Question q
+                where q.mockApply.id = :mockApplyId
+            )
             """)
     void deleteAllByMockApplyId(`@Param`("mockApplyId") Long mockApplyId);
🤖 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 - 24, Rewrite deleteAllByMockApplyId to replace the relationship
traversals in its JPQL DELETE predicate with explicit subqueries, matching the
established pattern used by deleteAllByJobPostingId. Preserve both deletion
conditions through analysis and question while binding mockApplyId consistently.
🤖 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.

Nitpick comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java`:
- Around line 17-24: Rewrite deleteAllByMockApplyId to replace the relationship
traversals in its JPQL DELETE predicate with explicit subqueries, matching the
established pattern used by deleteAllByJobPostingId. Preserve both deletion
conditions through analysis and question while binding mockApplyId consistently.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java`:
- Around line 53-57: Update the delete endpoint method associated with
`@DeleteMapping`("/{mockApplyId}") in MockApplyController by adding `@ApiResponses`
documentation for the successful deletion response and standard 401, 403, and
404 error responses, matching the annotation style used by the other controller
endpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a7fc7b4f-8b92-4d5b-bf85-da497db12bf2

📥 Commits

Reviewing files that changed from the base of the PR and between ba337d5 and 6973972.

📒 Files selected for processing (6)
  • 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/mockapply/controller/MockApplyController.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

QuestionAnalysisRepository.deleteAllByMockApplyId의 JPQL DELETE 조건을 관계 직접 탐색 대신 Analysis, Question 명시 subquery 방식으로 변경

MockApplyController의 DELETE /api/mock-applies/{mockApplyId}에 200, 401, 403, 404 @ApiResponses 문서 추가
@whc9999
whc9999 merged commit 5ec1d9e into dev Jul 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant