Skip to content
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: 과제 조회 API 추가 #543

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

Sangwook02
Copy link
Member

@Sangwook02 Sangwook02 commented Aug 1, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 과제 목록 조회과제 상세 조회 api를 구현했습니다.
  • 두 api에서 필요로 하는 응답 내용이 같아서 하나의 Dto로 처리했습니다.

📝 참고사항

📚 기타

Summary by CodeRabbit

  • 신규 기능

    • 스터디 과제를 조회할 수 있는 새로운 API 엔드포인트 추가.
    • 주간 과제 목록과 특정 과제의 세부 정보를 제공하는 기능 추가.
  • 버그 수정

    • 세부 정보를 찾을 수 없는 경우의 에러 처리를 개선하는 새로운 에러 코드 추가.
  • 문서화

    • API 문서화 개선을 위한 응답 객체 AssignmentResponse 추가.

@Sangwook02 Sangwook02 self-assigned this Aug 1, 2024
@Sangwook02 Sangwook02 requested a review from a team as a code owner August 1, 2024 02:58
@Sangwook02 Sangwook02 added the ✨ feature 새로운 기능 추가 및 수정 label Aug 1, 2024
Copy link

coderabbitai bot commented Aug 1, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

변경 사항은 멘토를 위한 과제 조회 API를 구현하여 주차별 과제 목록과 개별 과제 내용을 조회하는 기능을 추가합니다. 새로운 StudyMentorService가 도입되어 데이터 조회를 관리하며, AssignmentResponse DTO를 통해 클라이언트에 구조화된 응답을 제공합니다. 전체적으로 API의 기능성이 향상되었습니다.

Changes

파일 변경 요약
src/main/java/com/gdschongik/gdsc/domain/study/api/StudyMentorController.java 새로운 getWeeklyAssignmentsgetStudyAssignment 메소드 추가, StudyMentorService 의존성 통합
src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java getWeeklyAssignmentsgetAssignment 메소드로 과제 관리 기능 추가
src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java findAllByStudyId 메소드 추가로 데이터 조회 기능 향상
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentResponse.java 새로운 DTO 클래스 추가로 과제 응답 구조화
src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java STUDY_DETAIL_NOT_FOUND 오류 코드 추가로 오류 처리 기능 개선

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant MC as StudyMentorController
    participant MS as StudyMentorService
    participant R as StudyDetailRepository

    C->>MC: GET /studies/{studyId}/assignments
    MC->>MS: getWeeklyAssignments(studyId)
    MS->>R: findAllByStudyId(studyId)
    R-->>MS: List<StudyDetail>
    MS-->>MC: List<AssignmentResponse>
    MC-->>C: ResponseEntity<List<AssignmentResponse>>
Loading

Assessment against linked issues

Objective Addressed Explanation
주차별 과제 목록 조회 (#538)
과제 내용 조회 (#538)

🐰 변화의 노래를 부를게요,
과제들이 모여서 빛나네!
멘토들의 도움으로,
우리는 배우고 자라네!
새 기능, 새 기쁨,
함께로 더 좋아져요!
🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Aug 1, 2024

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

Copy link

@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

Outside diff range, codebase verification and nitpick comments (1)
src/main/java/com/gdschongik/gdsc/domain/study/api/StudyMentorController.java (1)

29-34: studyMentorService.getWeeklyAssignments 메서드의 오류 처리가 부족합니다.

현재 메서드는 올바르게 구현되어 있지만, studyDetailRepository.findAllByStudyId(studyId)가 빈 리스트나 null을 반환하는 경우를 처리하는 오류 처리가 필요합니다.

  • StudyMentorService.java 파일의 getWeeklyAssignments 메서드에 적절한 오류 처리를 추가하세요.
Analysis chain

studyMentorService.getWeeklyAssignments 메서드의 오류 처리를 확인하세요.

현재 메서드는 올바르게 구현되어 있습니다. 그러나 studyMentorService.getWeeklyAssignments 메서드가 오류를 적절히 처리하는지 확인해야 합니다.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling in `studyMentorService.getWeeklyAssignments`.

# Test: Search for the method implementation. Expect: Proper error handling.
rg --type java -A 10 $'public List<AssignmentResponse> getWeeklyAssignments'

Length of output: 1540

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 98241bc and e045867.

Files selected for processing (5)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/StudyMentorController.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentResponse.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java (1 hunks)
Additional context used
Learnings (1)
src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java (1)
Learnt from: Sangwook02
PR: GDSC-Hongik/gdsc-server#431
File: src/main/java/com/gdschongik/gdsc/domain/study/application/StudyService.java:50-57
Timestamp: 2024-07-07T15:32:34.451Z
Learning: Consider using Stream API for creating lists in a more concise and potentially performant manner compared to traditional for-loops.
Additional comments not posted (6)
src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java (2)

4-4: 필요한 import 추가

List를 사용하기 위해 필요한 import가 추가되었습니다.


7-10: 새로운 메서드 추가

StudyDetailRepository 인터페이스에 findAllByStudyId 메서드가 추가되었습니다. 이 메서드는 특정 studyId에 대한 StudyDetail 엔티티를 반환합니다.

src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentResponse.java (1)

1-23: 새로운 AssignmentResponse 레코드 추가

AssignmentResponse 레코드는 과제의 세부 정보를 캡슐화합니다. from 메서드는 StudyDetail 객체를 AssignmentResponse로 변환합니다.

src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java (1)

1-34: 새로운 StudyMentorService 클래스 추가

StudyMentorService 클래스는 과제 데이터를 조회하는 두 가지 메서드를 포함합니다. getWeeklyAssignments 메서드는 Stream API를 사용하여 StudyDetail 엔티티를 AssignmentResponse로 변환합니다.

src/main/java/com/gdschongik/gdsc/domain/study/api/StudyMentorController.java (1)

36-41: studyMentorService.getAssignment 메서드의 오류 처리를 확인하세요.

현재 메서드는 올바르게 구현되어 있습니다. 그러나 studyMentorService.getAssignment 메서드가 오류를 적절히 처리하는지 확인해야 합니다.

Verification successful

studyMentorService.getAssignment 메서드는 오류를 적절히 처리합니다.

studyMentorService.getAssignment 메서드는 StudyDetail을 찾지 못했을 때 CustomException을 던지도록 구현되어 있어 오류 처리가 적절합니다.

  • StudyMentorService.javagetAssignment 메서드에서 CustomException을 사용하여 오류를 처리하는 부분을 확인했습니다.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling in `studyMentorService.getAssignment`.

# Test: Search for the method implementation. Expect: Proper error handling.
rg --type java -A 10 $'public AssignmentResponse getAssignment'

Length of output: 950

src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java (1)

112-114: 새로운 오류 코드 STUDY_DETAIL_NOT_FOUND의 사용을 확인하세요.

새로운 오류 코드는 올바르게 추가되었습니다. 코드베이스에서 적절히 사용되고 있는지 확인해야 합니다.

Verification successful

새로운 오류 코드 STUDY_DETAIL_NOT_FOUND가 코드베이스에서 올바르게 사용되고 있습니다.

  • src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new error code `STUDY_DETAIL_NOT_FOUND`.

# Test: Search for the error code usage. Expect: Proper usage in the codebase.
rg --type java 'ErrorCode.STUDY_DETAIL_NOT_FOUND'

Length of output: 49


Script:

#!/bin/bash
# Description: Verify the usage of the new error code `STUDY_DETAIL_NOT_FOUND`.

# Test: Search for the usage of `STUDY_DETAIL_NOT_FOUND` in the codebase.
rg --type java 'STUDY_DETAIL_NOT_FOUND'

Length of output: 344

Comment on lines +21 to 27

@Operation(summary = "스터디 과제 개설", description = "멘토만 과제를 개설할 수 있습니다.")
@PutMapping("/assignment/{assignmentId}")
public ResponseEntity<Void> createStudyAssignment(
@PathVariable Long assignmentId, @Valid @RequestBody AssignmentCreateRequest request) {
return null;
}
Copy link

Choose a reason for hiding this comment

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

createStudyAssignment 메서드의 반환값을 수정하세요.

현재 메서드는 null을 반환하고 있습니다. 적절한 ResponseEntity를 반환하도록 수정해야 합니다.

- return null;
+ studyMentorService.createAssignment(assignmentId, request);
+ return ResponseEntity.ok().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.

Suggested change
@Operation(summary = "스터디 과제 개설", description = "멘토만 과제를 개설할 수 있습니다.")
@PutMapping("/assignment/{assignmentId}")
public ResponseEntity<Void> createStudyAssignment(
@PathVariable Long assignmentId, @Valid @RequestBody AssignmentCreateRequest request) {
return null;
}
@Operation(summary = "스터디 과제 개설", description = "멘토만 과제를 개설할 수 있습니다.")
@PutMapping("/assignment/{assignmentId}")
public ResponseEntity<Void> createStudyAssignment(
@PathVariable Long assignmentId, @Valid @RequestBody AssignmentCreateRequest request) {
studyMentorService.createAssignment(assignmentId, request);
return ResponseEntity.ok().build();
}

Copy link
Member

@AlmondBreez3 AlmondBreez3 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@uwoobeat uwoobeat left a comment

Choose a reason for hiding this comment

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

lgtm

@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Copy link
Member

Choose a reason for hiding this comment

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

메서드 레벨로 내려주세요

Copy link

github-actions bot commented Aug 2, 2024

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

@Sangwook02 Sangwook02 merged commit e1e4cf5 into develop Aug 2, 2024
1 check passed
@Sangwook02 Sangwook02 deleted the feature/538-mentor-get-assignment branch August 2, 2024 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 새로운 기능 추가 및 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 멘토 과제 조회 API 구현
3 participants