-
Notifications
You must be signed in to change notification settings - Fork 1
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: 과제 스터디 생성 로직 구현 #869
Conversation
Walkthrough이번 PR은 스터디 생성 로직에 분기 처리를 도입하여 라이브 스터디와 과제 스터디의 생성 방식을 구분합니다. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Controller
participant F as StudyFactory
participant V as StudyV2
participant S as StudySessionV2
C->>F: create(studyType, ...)
F->>F: studyType.isLive()?
alt 라이브 스터디
F->>V: createLive(...)
V->>S: createEmptyForLive(...)
else 과제 스터디
F->>V: createAssignment(...)
V->>S: createEmptyForAssignment(...)
end
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
✨ 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: 1
🧹 Nitpick comments (4)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactory.java (2)
64-99
: 메소드가 다소 길어 가독성이 떨어집니다.매개변수가 많아 메소드가 길어졌습니다. 빌더 패턴을 사용하여 가독성을 개선할 수 있습니다.
다음과 같은 리팩토링을 제안합니다:
+ @Builder + public static class LiveStudyParams { + private StudyType type; + private String title; + private String description; + // ... other fields + } - private StudyV2 createLive(StudyType type, String title, /* other params */) { + private StudyV2 createLive(LiveStudyParams params) { StudyV2 study = StudyV2.createLive( - type, - title, + params.getType(), + params.getTitle(), // ... other fields ); // ... rest of the method }
101-125
: Assignment 생성 메소드도 동일한 개선이 필요합니다.createAssignment 메소드도 매개변수가 많아 가독성이 떨어집니다.
위와 동일한 방식으로 빌더 패턴을 적용하여 가독성을 개선할 수 있습니다.
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyV2.java (1)
169-194
: 과제 스터디 생성 메소드가 잘 구현되어 있습니다.과제 스터디 생성 시 필요한 필드만 받아서 처리하는 것이 좋습니다. 다만, 파라미터가 많아 가독성이 떨어질 수 있습니다.
다음과 같이 빌더 패턴을 위한 DTO를 도입하는 것을 고려해보세요:
public static class AssignmentStudyCreateDto { private final String title; private final String description; // ... 나머지 필드들 @Builder public AssignmentStudyCreateDto(/* 필드들 */) { this.title = title; // ... 필드 초기화 } } public static StudyV2 createAssignment(AssignmentStudyCreateDto dto) { return StudyV2.builder() .type(StudyType.ASSIGNMENT) .title(dto.getTitle()) // ... 나머지 필드 설정 .build(); }src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyCreateRequest.java (1)
25-27
: 라이브 세션 필드들의 VO 분리 제안이 적절합니다.TODO 코멘트에서 제안된 대로 라이브 세션 관련 필드들(dayOfWeek, startTime, endTime)을 별도의 VO로 분리하면 다음과 같은 이점이 있습니다:
- 관련 필드들의 응집도 향상
- 유효성 검증 로직의 캡슐화
- 코드의 가독성 및 유지보수성 향상
LiveSessionInfo VO 구현에 대한 예시 코드를 제공해드릴까요?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyType.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/api/AdminStudyControllerV2.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactory.java
(2 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudySessionV2.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyV2.java
(4 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyCreateRequest.java
(2 hunks)src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java
(1 hunks)src/test/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactoryTest.java
(3 hunks)
🔇 Additional comments (12)
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyType.java (1)
15-17
: 구현이 명확하고 깔끔합니다!
isLive()
메소드가 명확한 의도를 가지고 있으며, enum 비교를 적절하게 사용하고 있습니다.src/main/java/com/gdschongik/gdsc/domain/studyv2/api/AdminStudyControllerV2.java (1)
23-23
: API 문서화가 개선되었습니다!과제 스터디의 필드 요구사항이 명확하게 문서화되어 있어 API 사용자가 이해하기 쉽습니다.
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudySessionV2.java (1)
95-101
: 🛠️ Refactor suggestion메소드 이름이 명확해졌으나 검증 로직이 필요합니다.
필수 필드에 대한 유효성 검사가 누락되어 있습니다. position과 studyV2가 null이 아님을 보장하는 검증이 필요합니다.
다음과 같이 검증 로직을 추가하는 것을 제안합니다:
public static void createEmptyForLive(Integer position, String lessonAttendanceNumber, StudyV2 studyV2) { + Objects.requireNonNull(position, "position must not be null"); + Objects.requireNonNull(studyV2, "studyV2 must not be null"); StudySessionV2.builder() .position(position) .lessonAttendanceNumber(lessonAttendanceNumber) .studyV2(studyV2) .build(); }src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactory.java (1)
34-62
: 분기 처리가 명확합니다!타입에 따른 분기 처리가 명확하고 이해하기 쉽습니다.
src/test/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactoryTest.java (3)
51-77
: 테스트 케이스가 과제 스터디의 필드 검증을 잘 수행하고 있습니다.과제 스터디 생성 시 라이브 세션 관련 필드(요일, 시작/종료 시간)가 null로 설정되는지 확인하는 테스트가 잘 구현되어 있습니다.
109-110
: 메소드 이름이 명확하게 변경되었습니다.테스트 메소드 이름이 '라이브 스터디'에 특화된 것임을 명확히 하도록 변경된 것이 좋습니다.
138-164
: 과제 스터디의 출석 번호 검증이 잘 구현되어 있습니다.과제 스터디의 세션에는 출석 번호가 생성되지 않아야 한다는 요구사항을 잘 검증하고 있습니다.
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyV2.java (2)
128-161
: 라이브 스터디 생성 로직이 잘 구현되어 있습니다.타입 검증을 통해 라이브 스터디 생성을 안전하게 처리하고 있습니다.
163-167
: 타입 검증 로직이 명확합니다.라이브 스터디 타입이 아닌 경우 적절한 예외를 발생시키는 검증 로직이 잘 구현되어 있습니다.
src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java (1)
110-110
: 에러 코드가 명확하게 정의되어 있습니다.스터디 타입 검증 실패에 대한 에러 메시지가 명확하고 적절한 HTTP 상태 코드가 사용되었습니다.
src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyCreateRequest.java (2)
6-6
: jakarta.annotation.Nullable 임포트 추가가 적절합니다.Jakarta EE의 @nullable 어노테이션을 사용하여 필드의 null 허용 여부를 명시적으로 표현한 것이 좋습니다.
20-22
: 라이브 세션 관련 필드들의 Nullable 처리가 적절합니다.과제 스터디의 경우 라이브 세션 정보가 필요하지 않으므로, dayOfWeek, startTime, endTime 필드를 @nullable로 처리한 것이 적절합니다. 하지만 이러한 필드들의 유효성 검증을 위한 추가적인 로직이 필요할 수 있습니다.
라이브 스터디의 경우 이 필드들이 반드시 존재해야 하는지 검증하는 로직이 있는지 확인이 필요합니다:
public static void createEmptyForAssignment(Integer position, StudyV2 studyV2) { | ||
StudySessionV2.builder().position(position).studyV2(studyV2).build(); | ||
} |
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.
🛠️ Refactor suggestion
동일한 검증 로직이 필요합니다.
createEmptyForAssignment 메소드도 필수 필드 검증이 필요합니다.
다음과 같이 검증 로직을 추가하는 것을 제안합니다:
public static void createEmptyForAssignment(Integer position, StudyV2 studyV2) {
+ Objects.requireNonNull(position, "position must not be null");
+ Objects.requireNonNull(studyV2, "studyV2 must not be null");
StudySessionV2.builder().position(position).studyV2(studyV2).build();
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public static void createEmptyForAssignment(Integer position, StudyV2 studyV2) { | |
StudySessionV2.builder().position(position).studyV2(studyV2).build(); | |
} | |
public static void createEmptyForAssignment(Integer position, StudyV2 studyV2) { | |
Objects.requireNonNull(position, "position must not be null"); | |
Objects.requireNonNull(studyV2, "studyV2 must not be null"); | |
StudySessionV2.builder().position(position).studyV2(studyV2).build(); | |
} |
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
🌱 관련 이슈
📌 작업 내용 및 특이사항
📝 참고사항
📚 기타
Summary by CodeRabbit
New Features
Refactor
Tests