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 구현 #911

Merged
merged 9 commits into from
Feb 23, 2025

Conversation

uwoobeat
Copy link
Member

@uwoobeat uwoobeat commented Feb 22, 2025

🌱 관련 이슈

📌 작업 내용 및 특이사항

기존과 동일하긴 한데, 사소한 변경사항이 있습니다.

  • 인프라 계층을 서비스 계층에서 알지 못하게 GithubClient로부터 GHRepository 를 직접 가져오는 대신 레포지터리 오우너 정보만 가져오도록 개선했습니다.
  • 도메인 서비스 검증 로직에서 현재 로그인한 유저의 oauthId와 레포지터리 오우너의 github ID 검증하는 로직에서 인자를 멤버 엔티티로 받도록 개선했습니다.
  • 문자열 비교 시 NPE 방지 위해 Objects.equals() 사용하도록 변경했습니다.

0223 20:11 업데이트 사항

  • API 엔드포인트 정보 및 요청 방식을 변경했습니다.
  • 기존에는 /study-histories/{studyId} 와 같은 식이었는데요, 스터디 수강이력은 스터디 수강이력 ID로 식별해야 하며 studyId로 검색하고 싶은 경우 /study-histories?studyId={studyId} 와 같은 식으로 설계되어야 합니다.
  • 단 get 요청이 아니므로 요청 파라미터를 사용하지 않고, 요청 바디 안에 studyId를 같이 담아서 전달해줘야 합니다.
  • 또한, 현재 로그인한 유저 정보를 사용하여 데이터의 유형이 결정되는 my 계열 API의 경우, /me suffix를 붙여주는 것이 적절합니다.
  • 따라서 PUT /study-histories/repositories/me 가 적절하다고 판단했습니다.
  • 또한 컨벤션에 맞게 메서드명을 updateRepository()updateMyRepository() 로 변경했습니다.

📝 참고사항

📚 기타

Summary by CodeRabbit

  • 새로운 기능
    • 학생 스터디 기록의 저장소 링크를 업데이트할 수 있는 API 엔드포인트가 추가되었습니다.
    • 업데이트 과정에서 GitHub 저장소 소유자 검증 및 입력 값 유효성 검사가 강화되어, 보다 안전한 변경이 가능합니다.
    • 사용자에게 안정적인 기록 관리를 제공하여 업데이트 시 발생할 수 있는 오류를 사전에 방지합니다.

@uwoobeat uwoobeat requested a review from a team as a code owner February 22, 2025 12:24
@uwoobeat uwoobeat self-assigned this Feb 22, 2025
Copy link

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

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 bot commented Feb 22, 2025

📝 Walkthrough

Walkthrough

새로운 API 기능이 추가되었습니다. StudentStudyHistoryControllerV2 컨트롤러 및 StudentStudyHistoryServiceV2 서비스 클래스가 도입되어 PUT 요청을 통해 학생의 스터디 기록에 관련된 저장소 링크를 업데이트합니다. 또한, 관련 유효성 검사 로직과 저장소 조회, GitHub 클라이언트의 owner ID 조회 기능이 확장되었습니다.

Changes

파일 또는 파일 그룹 변경 요약
src/main/java/.../api/StudentStudyHistoryControllerV2.java
src/main/java/.../application/StudentStudyHistoryServiceV2.java
새로운 컨트롤러와 서비스 클래스가 추가되어 PUT 요청에 따른 저장소 업데이트 로직(updateMyRepository 메서드)이 구현됨.
src/main/java/.../dao/StudyHistoryV2Repository.java
src/main/java/.../domain/StudyHistoryValidatorV2.java
StudyHistoryV2 저장소 인터페이스에 학생과 스터디 기반 조회 메서드 추가, Validator에 저장소 업데이트 검증을 위한 validateUpdateRepository 메서드 추가됨.
src/main/java/.../dto/request/StudyHistoryRepositoryUpdateRequest.java 저장소 링크를 담은 요청 DTO(record) 파일이 추가되어, 저장소 링크에 대한 유효성 검증(@notblank, @pattern)이 적용됨.
src/main/java/.../infra/github/client/GithubClient.java GitHub 저장소의 owner ID를 반환하는 getOwnerId 메서드가 추가되어, 저장소 업데이트 시 소유자 검증에 활용됨.

Sequence Diagram(s)

sequenceDiagram
    participant C as Controller
    participant S as Service
    participant R as StudyHistoryRepository
    participant V as Validator
    participant G as GithubClient
    participant M as MemberUtil

    C->>S: updateMyRepository(studyId, request)
    S->>M: getCurrentMember()
    S->>R: find study by studyId
    S->>R: find StudyHistory by (member, study)
    S->>G: getOwnerId(repositoryLink)
    G-->>S: ownerId
    S->>V: validateUpdateRepository(ownerId, currentMember)
    V-->>S: 검증 완료 혹은 예외 발생
    S->>R: save 업데이트된 StudyHistory
    S-->>C: HTTP 200 OK
Loading

Possibly related PRs

Suggested labels

✨ feature

Poem

나는 귀여운 토끼,
새로운 코드가 담긴 들판을 뛰네.
스터디 기록 업데이트, 깔끔한 흐름 따라
컨트롤러에서 서비스로, 깃허브까지 고고!
코드가 춤추듯 논리의 리듬, 😊
개발자 마음에도 봄바람 불어오네.
튼튼한 코드와 함께, 즐거운 하루 보내세요!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

coderabbitai bot commented Feb 22, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 0

🧹 Nitpick comments (4)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyHistoryValidatorV2.java (1)

20-20: 한글 주석을 영문으로 변경하는 것이 좋겠습니다.

국제화 및 일관성을 위해 영문 주석 사용을 권장드립니다.

-        // 레포지토리 소유자가 현 멤버가 아닌 경우
+        // Throw exception if repository owner is not the current member
src/main/java/com/gdschongik/gdsc/domain/studyv2/api/StudentStudyHistoryControllerV2.java (1)

26-30: 응답 처리를 더 구체적으로 개선하면 좋겠습니다.

현재는 단순히 200 OK를 반환하고 있습니다. 다음과 같은 개선을 제안드립니다:

  1. 성공 시 업데이트된 리소스의 위치를 반환
  2. 적절한 응답 본문 추가
-    public ResponseEntity<Void> updateRepository(
+    public ResponseEntity<StudyHistoryResponse> updateRepository(
         @PathVariable Long studyId, @Valid @RequestBody StudyHistoryRepositoryUpdateRequest request) {
         studentStudyHistoryServiceV2.updateRepository(studyId, request);
-        return ResponseEntity.ok().build();
+        return ResponseEntity
+                .ok()
+                .location(URI.create("/v2/study-history/" + studyId))
+                .body(new StudyHistoryResponse(studyId, request.repositoryLink()));
     }
src/main/java/com/gdschongik/gdsc/domain/studyv2/application/StudentStudyHistoryServiceV2.java (1)

31-49: 레포지토리 업데이트 로직에 대한 개선 제안

현재 구현은 기능적으로는 문제가 없으나, 다음 사항들을 고려해보시기 바랍니다:

  1. GitHub 레포지토리 링크 유효성 검사가 필요합니다
  2. 예외 처리 시 더 구체적인 메시지가 도움될 수 있습니다

다음과 같이 개선해보시는 것을 제안드립니다:

 @Transactional
 public void updateRepository(Long studyId, StudyHistoryRepositoryUpdateRequest request) {
     Member currentMember = memberUtil.getCurrentMember();
     StudyV2 study = studyV2Repository.findById(studyId).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND));
     StudyHistoryV2 studyHistory = studyHistoryV2Repository
             .findByStudentAndStudy(currentMember, study)
             .orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND));
+    if (!isValidGithubRepositoryUrl(request.repositoryLink())) {
+        throw new CustomException(INVALID_GITHUB_REPOSITORY_URL);
+    }
     String repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());

     studyHistoryValidatorV2.validateUpdateRepository(repositoryOwnerId, currentMember);

     studyHistory.updateRepositoryLink(request.repositoryLink());
     studyHistoryV2Repository.save(studyHistory);

     log.info(
             "[료StudentStudyHistoryServiceV2] 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
             studyHistory.getId(),
             request.repositoryLink());
 }

+private boolean isValidGithubRepositoryUrl(String url) {
+    return url != null && url.matches("^https://github\\.com/[\\w-]+/[\\w-]+$");
+}
src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java (1)

42-48: getOwnerId 메소드에 대한 개선 제안

메소드가 기본적인 기능은 잘 수행하고 있으나, 다음과 같은 개선사항을 제안드립니다:

  1. Javadoc 문서화 추가
  2. null 체크 추가

다음과 같이 개선해보시는 것을 제안드립니다:

+/**
+ * GitHub 레포지토리의 소유자 ID를 조회합니다.
+ *
+ * @param repo GitHub 레포지토리 URL
+ * @return 레포지토리 소유자의 ID
+ * @throws CustomException GITHUB_REPOSITORY_NOT_FOUND (레포지토리를 찾을 수 없는 경우)
+ */
 public String getOwnerId(String repo) {
+    if (repo == null || repo.trim().isEmpty()) {
+        throw new CustomException(INVALID_REPOSITORY_URL);
+    }
     try {
         return String.valueOf(getRepository(repo).getOwner().getId());
     } catch (IOException e) {
         throw new CustomException(GITHUB_REPOSITORY_NOT_FOUND);
     }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0839082 and 850990f.

📒 Files selected for processing (6)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/api/StudentStudyHistoryControllerV2.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/application/StudentStudyHistoryServiceV2.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/dao/StudyHistoryV2Repository.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyHistoryValidatorV2.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyHistoryRepositoryUpdateRequest.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/gdschongik/gdsc/domain/studyv2/dao/StudyHistoryV2Repository.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.
🔇 Additional comments (5)
src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyHistoryRepositoryUpdateRequest.java (1)

7-8: 깔끔한 DTO 구현을 확인했습니다!

Record를 사용한 불변 DTO 구현과 적절한 유효성 검증 애노테이션 적용이 잘 되어있습니다.

src/main/java/com/gdschongik/gdsc/domain/studyv2/dao/StudyHistoryV2Repository.java (1)

10-10: 리포지토리 메서드 구현이 적절합니다!

JPA 명명 규칙을 잘 따르고 있으며, DDD 원칙에 맞게 구현되어 있습니다.

src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyHistoryValidatorV2.java (1)

19-26: 검증 로직이 명확하게 구현되어 있습니다!

소유권 검증 로직이 명확하고 예외 처리가 적절합니다.

src/main/java/com/gdschongik/gdsc/domain/studyv2/api/StudentStudyHistoryControllerV2.java (1)

16-16: API 문서화가 잘 되어있습니다!

Swagger 애노테이션을 통한 API 문서화가 명확하게 작성되어 있습니다.

src/main/java/com/gdschongik/gdsc/domain/studyv2/application/StudentStudyHistoryServiceV2.java (1)

1-30: 클래스 구조가 잘 설계되어 있습니다.

의존성 주입과 트랜잭션 관리가 적절하게 구현되어 있습니다.

Copy link
Member

@Sangwook02 Sangwook02 left a comment

Choose a reason for hiding this comment

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

한가지 남겼는데 병목 있다고 하셔서 일단 어푸루브 했어요~


@Tag(name = "Student Study History V2", description = "학생 스터디 수강이력 API입니다.")
@RestController
@RequestMapping("/v2/study-history")
Copy link
Member

Choose a reason for hiding this comment

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

이건 histories로 안 해도 되려나요?

Copy link
Member

@kckc0608 kckc0608 left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines 45 to 46
log.info(
"[료StudentStudyHistoryServiceV2] 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
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

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

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

🧹 Nitpick comments (1)
src/main/java/com/gdschongik/gdsc/domain/studyv2/api/StudentStudyHistoryControllerV2.java (1)

23-28: 응답 타입과 문서화를 개선할 수 있습니다.

  1. 현재 ResponseEntity<Void>를 반환하고 있는데, 업데이트된 리소스의 정보를 포함하는 것이 RESTful API 설계에 더 적합할 수 있습니다.
  2. OpenAPI 문서화에 가능한 응답 코드와 예외 상황도 추가하면 좋을 것 같습니다.

예시:

@Operation(
    summary = "내 레포지토리 입력",
    description = "나의 과제 제출 레포지토리를 입력합니다.",
    responses = {
        @ApiResponse(responseCode = "200", description = "성공적으로 업데이트됨"),
        @ApiResponse(responseCode = "404", description = "스터디 또는 수강이력을 찾을 수 없음"),
        @ApiResponse(responseCode = "400", description = "잘못된 요청")
    }
)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 850990f and 167d5a3.

📒 Files selected for processing (3)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/api/StudentStudyHistoryControllerV2.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/application/StudentStudyHistoryServiceV2.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyHistoryRepositoryUpdateRequest.java (1 hunks)
🔇 Additional comments (2)
src/main/java/com/gdschongik/gdsc/domain/studyv2/dto/request/StudyHistoryRepositoryUpdateRequest.java (1)

9-11: 코드가 깔끔하고 잘 구현되어 있습니다!

Record를 사용한 DTO 구현과 적절한 validation 제약 조건이 잘 적용되어 있습니다.

src/main/java/com/gdschongik/gdsc/domain/studyv2/application/StudentStudyHistoryServiceV2.java (1)

25-29: 의존성 주입이 잘 구현되어 있습니다.

필요한 의존성들이 명확하게 정의되어 있고, @RequiredArgsConstructor를 통한 생성자 주입이 잘 구현되어 있습니다.

Comment on lines +31 to +50
@Transactional
public void updateMyRepository(StudyHistoryRepositoryUpdateRequest request) {
Member currentMember = memberUtil.getCurrentMember();
StudyV2 study =
studyV2Repository.findById(request.studyId()).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND));
StudyHistoryV2 studyHistory = studyHistoryV2Repository
.findByStudentAndStudy(currentMember, study)
.orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND));
String repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());

studyHistoryValidatorV2.validateUpdateRepository(repositoryOwnerId, currentMember);

studyHistory.updateRepositoryLink(request.repositoryLink());
studyHistoryV2Repository.save(studyHistory);

log.info(
"[StudentStudyHistoryServiceV2] 내 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
studyHistory.getId(),
request.repositoryLink());
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

예외 처리와 로깅을 개선할 수 있습니다.

  1. GitHub API 호출 시 발생할 수 있는 예외에 대한 처리가 필요합니다.
  2. 로그 메시지에 예외 상황에 대한 정보도 포함하면 좋을 것 같습니다.

다음과 같이 개선해보세요:

 @Transactional
 public void updateMyRepository(StudyHistoryRepositoryUpdateRequest request) {
     Member currentMember = memberUtil.getCurrentMember();
+    log.debug("[StudentStudyHistoryServiceV2] 레포지토리 업데이트 시작: memberId={}, studyId={}", 
+            currentMember.getId(), request.studyId());
     
     StudyV2 study =
             studyV2Repository.findById(request.studyId()).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND));
     StudyHistoryV2 studyHistory = studyHistoryV2Repository
             .findByStudentAndStudy(currentMember, study)
             .orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND));
-    String repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());
+    
+    String repositoryOwnerId;
+    try {
+        repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());
+    } catch (Exception e) {
+        log.error("[StudentStudyHistoryServiceV2] GitHub API 호출 실패: {}", e.getMessage());
+        throw new CustomException(GITHUB_API_ERROR);
+    }

     studyHistoryValidatorV2.validateUpdateRepository(repositoryOwnerId, currentMember);

     studyHistory.updateRepositoryLink(request.repositoryLink());
     studyHistoryV2Repository.save(studyHistory);

     log.info(
             "[StudentStudyHistoryServiceV2] 내 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
             studyHistory.getId(),
             request.repositoryLink());
 }
📝 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
@Transactional
public void updateMyRepository(StudyHistoryRepositoryUpdateRequest request) {
Member currentMember = memberUtil.getCurrentMember();
StudyV2 study =
studyV2Repository.findById(request.studyId()).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND));
StudyHistoryV2 studyHistory = studyHistoryV2Repository
.findByStudentAndStudy(currentMember, study)
.orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND));
String repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());
studyHistoryValidatorV2.validateUpdateRepository(repositoryOwnerId, currentMember);
studyHistory.updateRepositoryLink(request.repositoryLink());
studyHistoryV2Repository.save(studyHistory);
log.info(
"[StudentStudyHistoryServiceV2] 내 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
studyHistory.getId(),
request.repositoryLink());
}
@Transactional
public void updateMyRepository(StudyHistoryRepositoryUpdateRequest request) {
Member currentMember = memberUtil.getCurrentMember();
log.debug("[StudentStudyHistoryServiceV2] 레포지토리 업데이트 시작: memberId={}, studyId={}",
currentMember.getId(), request.studyId());
StudyV2 study =
studyV2Repository.findById(request.studyId())
.orElseThrow(() -> new CustomException(STUDY_NOT_FOUND));
StudyHistoryV2 studyHistory = studyHistoryV2Repository
.findByStudentAndStudy(currentMember, study)
.orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND));
String repositoryOwnerId;
try {
repositoryOwnerId = githubClient.getOwnerId(request.repositoryLink());
} catch (Exception e) {
log.error("[StudentStudyHistoryServiceV2] GitHub API 호출 실패: {}", e.getMessage());
throw new CustomException(GITHUB_API_ERROR);
}
studyHistoryValidatorV2.validateUpdateRepository(repositoryOwnerId, currentMember);
studyHistory.updateRepositoryLink(request.repositoryLink());
studyHistoryV2Repository.save(studyHistory);
log.info(
"[StudentStudyHistoryServiceV2] 내 레포지토리 입력 완료: studyHistoryId={}, repositoryLink={}",
studyHistory.getId(),
request.repositoryLink());
}

Copy link
Member

@kckc0608 kckc0608 left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@Sangwook02 Sangwook02 left a comment

Choose a reason for hiding this comment

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

lgtm

@uwoobeat uwoobeat merged commit 76ff563 into develop Feb 23, 2025
2 checks passed
@uwoobeat uwoobeat deleted the feature/910-study-history-put-repository branch February 23, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 스터디 수강이력 레포지터리 입력 V2 API 구현
3 participants