-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 쿠폰 도메인의 스터디 레퍼런스 변경 #905
Conversation
Caution Review failedThe pull request is closed. Walkthrough이번 PR은 기존의 Study 및 StudyHistory 도메인 대신 새로운 StudyV2 및 StudyHistoryV2를 사용하도록 쿠폰 관련 서비스, DAO, 도메인 및 유틸리티 클래스를 리팩토링합니다. 메서드 시그니처, 필드 타입, 임포트 문 등이 전면 수정되었으며, 이에 맞추어 테스트 코드와 헬퍼 클래스도 업데이트되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant CS as CouponService
participant SR as StudyV2Repository
participant CR as CouponRepository
CS->>SR: StudyV2 데이터 조회 요청
SR-->>CS: StudyV2 데이터 반환
CS->>CR: StudyV2 기반 쿠폰 조회/생성 요청
CR-->>CS: 쿠폰 조회 결과/생성 완료 응답
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Job Summary for GradleCheck Style and Test to Develop :: build-test
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java (1)
107-125
: 🛠️ Refactor suggestion스터디 이력 검증 로직 추가 필요
studyHistories가 비어있는 경우나 서로 다른 스터디의 이력이 포함된 경우에 대한 검증이 필요합니다.
@Transactional public void createAndIssueCouponByStudyHistories(List<Long> studyHistoryIds) { List<StudyHistoryV2> studyHistories = studyHistoryRepository.findAllById(studyHistoryIds); + if (studyHistories.isEmpty()) { + throw new CustomException(STUDY_HISTORY_NOT_FOUND); + } + + StudyV2 study = studyHistories.get(0).getStudy(); + boolean hasDifferentStudy = studyHistories.stream() + .map(StudyHistoryV2::getStudy) + .anyMatch(s -> !s.equals(study)); + if (hasDifferentStudy) { + throw new CustomException(INVALID_STUDY_HISTORIES); + } + List<Long> studentIds = studyHistories.stream() .map(studyHistory -> studyHistory.getStudent().getId()) .toList(); List<Member> students = memberRepository.findAllById(studentIds); - StudyV2 study = studyHistories.get(0).getStudy();
🧹 Nitpick comments (4)
src/main/java/com/gdschongik/gdsc/domain/coupon/domain/Coupon.java (2)
29-29
: 테이블 제약조건 변경 확인 필요데이터베이스 마이그레이션 작업이 필요할 수 있습니다. 기존 study_id를 사용하는 제약조건에서 study_v2_id로 변경되었습니다.
프로덕션 데이터베이스 마이그레이션 계획을 수립하고 실행해야 합니다.
49-51
: 연관관계 매핑 변경 확인StudyV2로의 연관관계 매핑이 올바르게 설정되었습니다. 단, 기존 Study 엔티티와의 데이터 마이그레이션 계획이 필요합니다.
기존 Study 엔티티와 연결된 쿠폰 데이터의 마이그레이션 전략을 수립해야 합니다.
src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java (1)
130-130
: 할인 금액 상수화 필요이전 PR #847의 피드백에 따라, 스터디 수료 쿠폰의 할인 금액(Money.FIVE_THOUSAND)을 상수로 분리하는 것이 좋습니다.
+private static final Money STUDY_COMPLETION_DISCOUNT_AMOUNT = Money.FIVE_THOUSAND; private Coupon findOrCreate(CouponType couponType, StudyV2 study) { return couponRepository.findByCouponTypeAndStudy(couponType, study).orElseGet(() -> { String couponName = couponNameUtil.generateStudyCompletionCouponName(study); - Coupon coupon = Coupon.createAutomatic(couponName, Money.FIVE_THOUSAND, couponType, study); + Coupon coupon = Coupon.createAutomatic(couponName, STUDY_COMPLETION_DISCOUNT_AMOUNT, couponType, study); return couponRepository.save(coupon); }); }src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java (1)
327-330
: 메서드 문서화가 필요합니다!createStudyHistory 메서드가 잘 구현되었지만, 메서드의 목적과 사용법을 설명하는 JavaDoc 문서화가 추가되면 좋을 것 같습니다.
다음과 같이 문서화를 추가해보세요:
+ /** + * StudyV2와 연관된 StudyHistoryV2를 생성합니다. + * + * @param member 스터디 참여 멤버 + * @param study 참여할 스터디 + * @return 생성된 스터디 히스토리 + */ protected StudyHistoryV2 createStudyHistory(Member member, StudyV2 study) { StudyHistoryV2 studyHistory = StudyHistoryV2.create(member, study); return studyHistoryV2Repository.save(studyHistory); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java
(5 hunks)src/main/java/com/gdschongik/gdsc/domain/coupon/dao/CouponRepository.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/coupon/dao/IssuedCouponCustomRepository.java
(2 hunks)src/main/java/com/gdschongik/gdsc/domain/coupon/dao/IssuedCouponCustomRepositoryImpl.java
(2 hunks)src/main/java/com/gdschongik/gdsc/domain/coupon/domain/Coupon.java
(4 hunks)src/main/java/com/gdschongik/gdsc/domain/coupon/util/CouponNameUtil.java
(2 hunks)src/test/java/com/gdschongik/gdsc/domain/coupon/application/CouponServiceTest.java
(5 hunks)src/test/java/com/gdschongik/gdsc/domain/coupon/util/CouponNameUtilTest.java
(2 hunks)src/test/java/com/gdschongik/gdsc/helper/FixtureHelper.java
(1 hunks)src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java
(4 hunks)
🧰 Additional context used
🧠 Learnings (2)
src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java (1)
Learnt from: uwoobeat
PR: GDSC-Hongik/gdsc-server#889
File: src/main/java/com/gdschongik/gdsc/domain/studyv2/api/MentorStudyControllerV2.java:35-39
Timestamp: 2025-02-12T11:11:19.196Z
Learning: In the GDSC server project's V2 domain, following DDD principles, StudyV2 is an aggregate root and StudySession is its child entity. Therefore, StudySession should only be accessed through StudyV2 aggregate root using StudyV2Repository, not directly via a separate StudySessionRepository.
src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java (1)
Learnt from: kckc0608
PR: GDSC-Hongik/gdsc-server#847
File: src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java:115-115
Timestamp: 2025-01-22T12:27:00.185Z
Learning: Discount amounts in the coupon domain should be managed as constants rather than hardcoded values, especially for specific coupon types like study completion coupons.
🔇 Additional comments (12)
src/main/java/com/gdschongik/gdsc/domain/coupon/dao/CouponRepository.java (1)
5-5
: Study에서 StudyV2로의 전환이 올바르게 이루어졌습니다!인터페이스의 메서드 시그니처와 임포트문이 새로운 StudyV2 도메인 모델과 일관되게 업데이트되었습니다.
Also applies to: 10-10
src/main/java/com/gdschongik/gdsc/domain/coupon/util/CouponNameUtil.java (1)
13-17
: 리팩토링으로 코드가 더 명확해졌습니다!StudyV2로의 전환과 함께 다음과 같은 개선사항이 있습니다:
- Semester 객체를 명시적으로 분리하여 가독성이 향상되었습니다
- SemesterFormatter 사용이 더 명확해졌습니다
src/main/java/com/gdschongik/gdsc/domain/coupon/dao/IssuedCouponCustomRepository.java (1)
7-7
: StudyV2 도메인으로의 전환이 정확하게 이루어졌습니다!커스텀 리포지토리 인터페이스의 메서드 시그니처와 임포트문이 새로운 도메인 모델과 일관되게 변경되었습니다.
Also applies to: 16-16
src/test/java/com/gdschongik/gdsc/domain/coupon/util/CouponNameUtilTest.java (1)
21-34
: Discord 관련 설정이 추가된 것을 확인해주세요.StudyV2로의 전환 과정에서 Discord 통합을 위한 새로운 매개변수들이 추가되었습니다:
- STUDY_DISCORD_CHANNEL_ID
- STUDY_DISCORD_ROLE_ID
이러한 변경사항들이 실제 운영 환경에서 예상대로 동작하는지 확인이 필요합니다.
src/main/java/com/gdschongik/gdsc/domain/coupon/dao/IssuedCouponCustomRepositoryImpl.java (1)
41-51
:❓ Verification inconclusive
메서드 시그니처 변경이 쿼리 로직에 미치는 영향 확인 필요
쿼리 로직이 StudyV2 엔티티와 정상적으로 동작하는지 확인이 필요합니다. 특히
coupon.study.eq(study)
부분에서 StudyV2의 연관관계가 올바르게 매핑되어 있는지 검증해야 합니다.
🏁 Script executed:
#!/bin/bash # StudyV2와 Coupon 간의 연관관계 매핑 확인 ast-grep --pattern 'class Coupon { $$$ @ManyToOne $$$ private StudyV2 study; $$$ }'Length of output: 95
쿼리 로직 및 StudyV2 매핑 수동 검증 필요
src/main/java/com/gdschongik/gdsc/domain/coupon/dao/IssuedCouponCustomRepositoryImpl.java
의 41-51번 라인에서 StudyV2로 변경된 파라미터를 사용하는 쿼리 로직(coupon.study.eq(study)
)이 의도한 대로 동작하는지 확인해야 합니다.- 자동 검증 스크립트 실행 결과(Coupon 엔티티에 StudyV2 연관 매핑 관련)가 출력되지 않아, Coupon 엔티티 내에서
private StudyV2 study;
어노테이션(@ManyToOne
등) 매핑이 올바르게 적용되었는지 수동으로 확인해 주시기 바랍니다.src/test/java/com/gdschongik/gdsc/helper/FixtureHelper.java (1)
92-95
: 테스트 헬퍼 메서드가 적절히 업데이트되었습니다StudyV2를 사용하도록 변경된 createAndIssue 메서드가 올바르게 구현되었습니다.
src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java (1)
43-49
: 의존성이 적절히 업데이트되었습니다StudyV2 관련 저장소들로 올바르게 변경되었습니다.
src/test/java/com/gdschongik/gdsc/domain/coupon/application/CouponServiceTest.java (3)
19-21
: 임포트 변경이 적절합니다!Study 도메인에서 StudyV2 도메인으로의 마이그레이션을 위한 임포트 변경이 올바르게 이루어졌습니다.
217-219
: 테스트 메서드의 타입 변경이 적절합니다!Study와 StudyHistory에서 StudyV2와 StudyHistoryV2로의 타입 변경이 일관되게 적용되었으며, 테스트 로직은 그대로 유지되었습니다.
236-260
: 전체 테스트 커버리지가 잘 유지되었습니다!모든 테스트 메서드에서 StudyV2와 StudyHistoryV2로의 변경이 일관되게 적용되었으며, 기존의 테스트 커버리지가 잘 유지되고 있습니다.
Also applies to: 279-282
src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java (2)
109-111
: StudyHistoryV2Repository 주입이 적절합니다!StudyV2 도메인으로의 마이그레이션을 위해 필요한 StudyHistoryV2Repository가 올바르게 주입되었습니다.
239-244
: createAndIssue 메서드의 파라미터 타입 변경이 적절합니다!Study에서 StudyV2로의 파라미터 타입 변경이 일관되게 적용되었으며, 메서드의 핵심 로직은 그대로 유지되었습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
하나만 봐주세요
@@ -20,18 +18,20 @@ class CouponNameUtilTest { | |||
void 스터디_수료_쿠폰_이름이_생성된다() { | |||
// given | |||
Member mentor = fixtureHelper.createMentor(1L); | |||
Study study = Study.create( | |||
StudyV2 study = StudyV2.createLive( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
픽스쳐 유틸을 쓰면 좋을듯요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
픽스쳐 헬퍼에 있는 메서드는 스터디 제목을 주입할 수 없어서 StudyV2에 있는 메서드를 직접 갖다 썼었어요.
assert문을 수정하고 픽스쳐 헬퍼 사용하도록 수정했습니다~
Job Summary for GradleCheck Style and Test to Develop :: build-test
|
🌱 관련 이슈
📌 작업 내용 및 특이사항
Coupon
에서Study
를StudyV2
로 변경했습니다.📝 참고사항
📚 기타
Summary by CodeRabbit