[Feat] #180 User 엔티티 ERD 정합 - 승격 시 지원서 개인정보 필드 추가#181
Conversation
평가 어드민 기능(#170) 추가 후 applicant_eval.applicant_id NOT NULL FK가 생겼으나 deleteApplicants가 이를 정리하지 않아, 평가가 존재하는 공고는 지원서 전체 삭제가 FK 제약 위반으로 실패하던 문제를 수정. - ApplicantEvalRepository.deleteByRecruitmentId 서브쿼리 벌크 삭제 추가 - deleteApplicants 삭제 순서를 eval -> answer -> applicant 로 정정 - 단위/리포지토리/통합 테스트에 평가 존재 케이스 회귀 테스트 추가
…eval [Fix] 지원서 전체 삭제 시 평가(applicant_eval) 미삭제로 인한 FK 위반 수정
- User에 email, minor_double_major, last_semester, military_status, birth_date, graduation_date, grad_school_plan 필드 추가 - MilitaryStatus enum을 global.common.enums로 이동 (Applicant/User 공용) - User.promote() 및 UserAdminService 승격 로직에 신규 필드 복사 반영 - UserAdminServiceTest / UserIntegrationTest 필드 복사 검증 확장
📝 WalkthroughWalkthrough공용 Changes지원자 및 사용자 데이터 흐름
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/main/java/com/boaz/backend/domain/recruitment/repository/ApplicantEvalRepository.java (1)
45-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value벌크 연산 후 영속성 컨텍스트 동기화를 고려해보면 어떨까요?
@Modifying어노테이션에flushAutomatically = true, clearAutomatically = true속성을 추가하는 것을 추천드려요! 벌크 삭제 쿼리가 실행된 후 영속성 컨텍스트를 비워주면, 이후 동일한 트랜잭션 내에서 남아있는 캐시로 인한 예기치 못한 데이터 불일치를 예방할 수 있답니다. 파일 상단의upsert메서드와 일관성을 맞출 수도 있어 더욱 좋을 것 같아요!✨ 이렇게 수정해보시는 건 어떨까요?
- `@Modifying` + `@Modifying`(flushAutomatically = true, clearAutomatically = true) `@Query`("DELETE FROM ApplicantEval e WHERE e.applicant.id IN (SELECT a.id FROM Applicant a WHERE a.recruitment.id = :recruitmentId)") void deleteByRecruitmentId(`@Param`("recruitmentId") Long recruitmentId);🤖 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/boaz/backend/domain/recruitment/repository/ApplicantEvalRepository.java` around lines 45 - 47, Update the `@Modifying` annotation on deleteByRecruitmentId to enable flushAutomatically and clearAutomatically, ensuring pending changes are flushed before the bulk delete and the persistence context is cleared afterward. Keep the existing delete query and method signature unchanged.src/test/java/com/boaz/backend/domain/recruitment/integration/RecruitmentIntegrationTest.java (1)
685-691: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFQCN(Full Qualified Class Name) 대신 import를 활용해보면 어떨까요?
현재
Admin엔티티와 관련된 클래스명들이 패키지명까지 모두 포함되어 있어 코드가 조금 길어졌어요. 파일 상단에import com.boaz.backend.domain.admin.entity.Admin;을 추가해 주시면 코드가 한결 간결하고 읽기 편해질 것 같아요! (만약 동음이의어 클래스 충돌이 있다면 지금처럼 명시적으로 쓰시는 것도 훌륭한 선택입니다 😊)✨ 이렇게 수정해보시는 건 어떨까요?
- com.boaz.backend.domain.admin.entity.Admin evaluator = adminRepository.save( - com.boaz.backend.domain.admin.entity.Admin.builder() + Admin evaluator = adminRepository.save( + Admin.builder() .username("evaluator-178").password("p") - .role(com.boaz.backend.domain.admin.entity.Admin.Role.TEAM).name("평가자") + .role(Admin.Role.TEAM).name("평가자") .track(Track.ENGINEERING).term(26) - .teamName(com.boaz.backend.domain.admin.entity.Admin.TeamName.서비스운영팀) + .teamName(Admin.TeamName.서비스운영팀) .createdBy(null).build());🤖 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/test/java/com/boaz/backend/domain/recruitment/integration/RecruitmentIntegrationTest.java` around lines 685 - 691, Replace the fully qualified Admin references in the evaluator setup with the imported Admin class, adding the Admin import at the file top; retain fully qualified names only if an actual class-name collision exists.src/main/java/com/boaz/backend/domain/user/entity/User.java (1)
86-104: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value파라미터 객체 도입을 고려해 보세요.
승격 시 전달해야 할 파라미터가 많이 늘어났네요! 도메인(User)이 다른 도메인(Applicant)에 직접 의존하지 않도록 필드를 풀어서 전달하는 현재의 방식도 의도가 명확해서 좋습니다.
다만 메서드의 파라미터 개수가 10개가 넘어가면 호출부에서 순서를 헷갈리기 쉬우니, 나중에 기회가 된다면
UserPromotionDto와 같은 전용 파라미터 객체(Record 등)를 도입해서 응집도를 높여보는 것도 좋은 개선 방향이 될 것 같아요! ✨🤖 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/boaz/backend/domain/user/entity/User.java` around lines 86 - 104, Consider introducing a dedicated promotion parameter object, such as UserPromotionDto or a record, for User.promote instead of passing the many individual promotion fields. Update promote and its call sites to consume the object while keeping User independent of Applicant by defining the object with only the required promotion values.
🤖 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/boaz/backend/domain/recruitment/repository/ApplicantEvalRepository.java`:
- Around line 45-47: Update the `@Modifying` annotation on deleteByRecruitmentId
to enable flushAutomatically and clearAutomatically, ensuring pending changes
are flushed before the bulk delete and the persistence context is cleared
afterward. Keep the existing delete query and method signature unchanged.
In `@src/main/java/com/boaz/backend/domain/user/entity/User.java`:
- Around line 86-104: Consider introducing a dedicated promotion parameter
object, such as UserPromotionDto or a record, for User.promote instead of
passing the many individual promotion fields. Update promote and its call sites
to consume the object while keeping User independent of Applicant by defining
the object with only the required promotion values.
In
`@src/test/java/com/boaz/backend/domain/recruitment/integration/RecruitmentIntegrationTest.java`:
- Around line 685-691: Replace the fully qualified Admin references in the
evaluator setup with the imported Admin class, adding the Admin import at the
file top; retain fully qualified names only if an actual class-name collision
exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e6db8623-0e72-4787-84d0-91960c01e9e0
📒 Files selected for processing (16)
src/main/java/com/boaz/backend/domain/recruitment/dto/request/ApplicationRequest.javasrc/main/java/com/boaz/backend/domain/recruitment/dto/request/DraftApplicationRequest.javasrc/main/java/com/boaz/backend/domain/recruitment/dto/response/ApplicantEvaluationResponse.javasrc/main/java/com/boaz/backend/domain/recruitment/dto/response/ApplicantSummaryResponse.javasrc/main/java/com/boaz/backend/domain/recruitment/dto/response/MyApplicationResponse.javasrc/main/java/com/boaz/backend/domain/recruitment/entity/Applicant.javasrc/main/java/com/boaz/backend/domain/recruitment/repository/ApplicantEvalRepository.javasrc/main/java/com/boaz/backend/domain/recruitment/service/RecruitmentService.javasrc/main/java/com/boaz/backend/domain/user/entity/User.javasrc/main/java/com/boaz/backend/domain/user/service/UserAdminService.javasrc/main/java/com/boaz/backend/global/common/enums/MilitaryStatus.javasrc/test/java/com/boaz/backend/domain/recruitment/integration/RecruitmentIntegrationTest.javasrc/test/java/com/boaz/backend/domain/recruitment/repository/ApplicantEvalRepositoryTest.javasrc/test/java/com/boaz/backend/domain/recruitment/service/RecruitmentServiceTest.javasrc/test/java/com/boaz/backend/domain/user/integration/UserIntegrationTest.javasrc/test/java/com/boaz/backend/domain/user/service/UserAdminServiceTest.java
💡 개요
🪐 주요 변경 사항
users테이블 스키마를 ERD와 정합화 (승격 시 지원서 개인정보 전체 복사)MilitaryStatusenum을Applicant내부 →global.common.enums로 이동 (Applicant/User 공용)✅ 상세 내용
User엔티티에 ERD 누락 필드 7종 추가:email,minor_double_major(JSON),last_semester,military_status,birth_date,graduation_date,grad_school_planUser.promote()및UserAdminService승격 로직이Applicant에서 7필드 전부 복사하도록 수정MilitaryStatus공용 이동에 따른 참조 6개 파일(요청/응답 DTO, 테스트) 갱신UserAdminServiceTest(TC-005) /UserIntegrationTest필드 복사 검증 확장, 전체 테스트 그린🔔 참고 사항
ddl-auto: validate→ 배포 전 RDSusers에 신규 컬럼 7종ALTER TABLE필수 (완료). 이미 승격된 MEMBER→OUTSIDER 원복 완료.변경 목적:
User엔티티를 ERD와 정합화하고, 지원서 승격 시 개인정보를 사용자 정보에 모두 반영합니다. 또한 지원서 삭제 시 평가 데이터의 외래 키 오류를 방지합니다.주요 변경 내용:
User엔티티에 이메일, 부전공, 마지막 학기, 군복무 상태, 생년월일, 졸업일, 대학원 진학 계획 필드 추가User.promote()및 승격 서비스에서Applicant의 개인정보 전체 복사MilitaryStatus를 공용 enum으로 이동하고 관련 DTO·엔티티·테스트 참조 변경ApplicantEval을 먼저 삭제하도록 로직 및 리포지토리 추가영향 범위:
militaryStatus타입이Applicant.MilitaryStatus에서 공용MilitaryStatus로 변경users테이블에 신규 컬럼 7종 추가 필요