From a91e0d72eb39feb7356337e3592d884024d430fa Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 18:21:09 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20StudyAchievementRepository=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/dao/StudyAchievementRepository.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java new file mode 100644 index 000000000..1dde50c3e --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java @@ -0,0 +1,12 @@ +package com.gdschongik.gdsc.domain.study.dao; + +import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface StudyAchievementRepository extends JpaRepository { + + List findAllByStudent(Member student); +} From ad6863be586d4fac6b1347e1ef8730c8cab88850 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 18:23:44 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=88=98=EB=A3=8C=20=EB=82=B4=EC=97=AD=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudentStudyHistoryService.java | 31 +++++++++------ .../domain/study/domain/StudyAchievement.java | 4 ++ .../StudentMyCompleteStudyResponse.java | 39 +++++++++++++++++++ 3 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index d631f3779..b141bf51f 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -3,20 +3,11 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.domain.study.dao.AssignmentHistoryRepository; -import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; -import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository; -import com.gdschongik.gdsc.domain.study.dao.StudyRepository; -import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; -import com.gdschongik.gdsc.domain.study.domain.AssignmentHistoryGrader; -import com.gdschongik.gdsc.domain.study.domain.AssignmentSubmissionFetcher; -import com.gdschongik.gdsc.domain.study.domain.Study; -import com.gdschongik.gdsc.domain.study.domain.StudyAssignmentHistoryValidator; -import com.gdschongik.gdsc.domain.study.domain.StudyDetail; -import com.gdschongik.gdsc.domain.study.domain.StudyHistory; -import com.gdschongik.gdsc.domain.study.domain.StudyHistoryValidator; +import com.gdschongik.gdsc.domain.study.dao.*; +import com.gdschongik.gdsc.domain.study.domain.*; import com.gdschongik.gdsc.domain.study.dto.request.RepositoryUpdateRequest; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryResponse; +import com.gdschongik.gdsc.domain.study.dto.response.StudentMyCompleteStudyResponse; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.util.MemberUtil; import com.gdschongik.gdsc.infra.github.client.GithubClient; @@ -44,6 +35,7 @@ public class StudentStudyHistoryService { private final StudyAssignmentHistoryValidator studyAssignmentHistoryValidator; private final AssignmentHistoryGrader assignmentHistoryGrader; private final StudyRepository studyRepository; + private final StudyAchievementRepository studyAchievementRepository; @Transactional public void updateRepository(Long studyId, RepositoryUpdateRequest request) throws IOException { @@ -107,6 +99,21 @@ public void submitAssignment(Long studyDetailId) { assignmentHistory.getSubmissionFailureType()); } + @Transactional(readOnly = true) + public List getMyCompleteStudies() { + Member currentMember = memberUtil.getCurrentMember(); + List studyHistories = studyHistoryRepository.findAllByStudent(currentMember); + List studyAchievements = studyAchievementRepository.findAllByStudent(currentMember); + + return studyHistories.stream().map(history -> { + List achievements = studyAchievements.stream() + .filter(studyAchievement -> studyAchievement.isSameStudyWithStudyHistory(history)) + .map(StudyAchievement::getAchievementType) + .toList(); + return StudentMyCompleteStudyResponse.of(history, achievements); + }).toList(); + } + private AssignmentHistory findOrCreate(Member currentMember, StudyDetail studyDetail) { return assignmentHistoryRepository .findByMemberAndStudyDetail(currentMember, studyDetail) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java index 64fd28b34..8b333fcbd 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java @@ -54,4 +54,8 @@ public static StudyAchievement create(Member student, Study study, AchievementTy .achievementType(achievementType) .build(); } + + public boolean isSameStudyWithStudyHistory(StudyHistory history) { + return this.study == history.getStudy(); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java new file mode 100644 index 000000000..b8efa74d7 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -0,0 +1,39 @@ +package com.gdschongik.gdsc.domain.study.dto.response; + +import com.gdschongik.gdsc.domain.common.model.SemesterType; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; +import com.gdschongik.gdsc.domain.study.domain.StudyHistory; +import com.gdschongik.gdsc.domain.study.domain.StudyHistoryStatus; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; + +public record StudentMyCompleteStudyResponse( + Long studyId, + @Schema(description = "학년도") Integer academicYear, + @Schema(description = "학기") SemesterType semesterType, + @Schema(description = "이름") String title, + @Schema(description = "종류") String studyType, + @Schema(description = "상세설명 노션 링크") String notionLink, + @Schema(description = "한 줄 소개") String introduction, + @Schema(description = "멘토 이름") String mentorName, + @Schema(description = "총 주차수") Long totalWeek, + @Schema(description = "수료 여부") StudyHistoryStatus studyHistoryStatus, + @Schema(description = "우수 스터디원 여부") List achievements +) { + + public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List achievements) { + return new StudentMyCompleteStudyResponse( + studyHistory.getStudy().getId(), + studyHistory.getStudy().getAcademicYear(), + studyHistory.getStudy().getSemesterType(), + studyHistory.getStudy().getTitle(), + studyHistory.getStudy().getStudyType().getValue(), + studyHistory.getStudy().getNotionLink(), + studyHistory.getStudy().getIntroduction(), + studyHistory.getStudy().getMentor().getName(), + studyHistory.getStudy().getTotalWeek(), + studyHistory.getStudyHistoryStatus(), + achievements + ); + } +} From 0a6dd71889ba73e42bbb879de06ee84ffc7e00c1 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 18:24:06 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=88=98=EB=A3=8C=EB=82=B4=EC=97=AD=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/api/StudentStudyHistoryController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java index 8764e5a95..884bc2f46 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java @@ -3,6 +3,7 @@ import com.gdschongik.gdsc.domain.study.application.StudentStudyHistoryService; import com.gdschongik.gdsc.domain.study.dto.request.RepositoryUpdateRequest; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryResponse; +import com.gdschongik.gdsc.domain.study.dto.response.StudentMyCompleteStudyResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; @@ -42,4 +43,11 @@ public ResponseEntity submitAssignment(@RequestParam(name = "studyDetailId studentStudyHistoryService.submitAssignment(studyDetailId); return ResponseEntity.ok().build(); } + + @Operation(summary = "내 스터디 수료 내역 조회", description = "내가 수료한 스터디를 조회합니다.") + @GetMapping("/me/complete") + public ResponseEntity> getMyCompleteStudy() { + List response = studentStudyHistoryService.getMyCompleteStudies(); + return ResponseEntity.ok(response); + } } From 57532d9be114ca61c207e2cff66bdcb751a71db6 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 19:55:47 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20=EC=9A=B0=EC=88=98=20?= =?UTF-8?q?=EC=8A=A4=ED=84=B0=EB=94=94=EC=9B=90=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudentStudyHistoryService.java | 24 +++++++++++++------ .../study/dao/StudyAchievementRepository.java | 3 +-- .../domain/study/domain/StudyAchievement.java | 4 ---- .../StudentMyCompleteStudyResponse.java | 6 ++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index b141bf51f..1c3456762 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -13,8 +13,11 @@ import com.gdschongik.gdsc.infra.github.client.GithubClient; import java.io.IOException; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.kohsuke.github.GHRepository; @@ -105,13 +108,20 @@ public List getMyCompleteStudies() { List studyHistories = studyHistoryRepository.findAllByStudent(currentMember); List studyAchievements = studyAchievementRepository.findAllByStudent(currentMember); - return studyHistories.stream().map(history -> { - List achievements = studyAchievements.stream() - .filter(studyAchievement -> studyAchievement.isSameStudyWithStudyHistory(history)) - .map(StudyAchievement::getAchievementType) - .toList(); - return StudentMyCompleteStudyResponse.of(history, achievements); - }).toList(); + Map> achievementsByStudy = studyAchievements.stream() + .collect(Collectors.groupingBy( + StudyAchievement::getStudy, + Collectors.mapping(StudyAchievement::getAchievementType, Collectors.toList()))); + + return studyHistories.stream() + .map(history -> { + List achievementTypes = achievementsByStudy.get(history.getStudy()); + if (achievementTypes == null) { + achievementTypes = new ArrayList<>(); + } + return StudentMyCompleteStudyResponse.of(history, achievementTypes); + }) + .toList(); } private AssignmentHistory findOrCreate(Member currentMember, StudyDetail studyDetail) { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java index 1dde50c3e..94b5f6e2b 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementRepository.java @@ -2,9 +2,8 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; public interface StudyAchievementRepository extends JpaRepository { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java index 8b333fcbd..64fd28b34 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java @@ -54,8 +54,4 @@ public static StudyAchievement create(Member student, Study study, AchievementTy .achievementType(achievementType) .build(); } - - public boolean isSameStudyWithStudyHistory(StudyHistory history) { - return this.study == history.getStudy(); - } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java index b8efa74d7..a77dbdab5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -18,8 +18,7 @@ public record StudentMyCompleteStudyResponse( @Schema(description = "멘토 이름") String mentorName, @Schema(description = "총 주차수") Long totalWeek, @Schema(description = "수료 여부") StudyHistoryStatus studyHistoryStatus, - @Schema(description = "우수 스터디원 여부") List achievements -) { + @Schema(description = "우수 스터디원 여부") List achievements) { public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List achievements) { return new StudentMyCompleteStudyResponse( @@ -33,7 +32,6 @@ public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List< studyHistory.getStudy().getMentor().getName(), studyHistory.getStudy().getTotalWeek(), studyHistory.getStudyHistoryStatus(), - achievements - ); + achievements); } } From a05192e013d09f3992fe5f6d5eadd454e50f9c51 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 20:09:33 +0900 Subject: [PATCH 05/11] =?UTF-8?q?chore:=20import=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EA=B8=B0=EC=A1=B4=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/StudentStudyHistoryService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 1c3456762..21d71739c 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -3,8 +3,21 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.domain.study.dao.*; -import com.gdschongik.gdsc.domain.study.domain.*; +import com.gdschongik.gdsc.domain.study.dao.AssignmentHistoryRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyAchievementRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyRepository; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; +import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; +import com.gdschongik.gdsc.domain.study.domain.AssignmentHistoryGrader; +import com.gdschongik.gdsc.domain.study.domain.AssignmentSubmissionFetcher; +import com.gdschongik.gdsc.domain.study.domain.Study; +import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; +import com.gdschongik.gdsc.domain.study.domain.StudyAssignmentHistoryValidator; +import com.gdschongik.gdsc.domain.study.domain.StudyDetail; +import com.gdschongik.gdsc.domain.study.domain.StudyHistory; +import com.gdschongik.gdsc.domain.study.domain.StudyHistoryValidator; import com.gdschongik.gdsc.domain.study.dto.request.RepositoryUpdateRequest; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryResponse; import com.gdschongik.gdsc.domain.study.dto.response.StudentMyCompleteStudyResponse; From 5bab5a6b6c5ab981a9db23631dbcbdf0ca4bf3c6 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 21:12:40 +0900 Subject: [PATCH 06/11] =?UTF-8?q?chore:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/api/StudentStudyHistoryController.java | 4 ++-- .../domain/study/application/StudentStudyHistoryService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java index 884bc2f46..1cf0bbb7a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java @@ -46,8 +46,8 @@ public ResponseEntity submitAssignment(@RequestParam(name = "studyDetailId @Operation(summary = "내 스터디 수료 내역 조회", description = "내가 수료한 스터디를 조회합니다.") @GetMapping("/me/complete") - public ResponseEntity> getMyCompleteStudy() { - List response = studentStudyHistoryService.getMyCompleteStudies(); + public ResponseEntity> getMyCompletedStudy() { + List response = studentStudyHistoryService.getMyCompletedStudies(); return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 21d71739c..1cfa3bca9 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -116,7 +116,7 @@ public void submitAssignment(Long studyDetailId) { } @Transactional(readOnly = true) - public List getMyCompleteStudies() { + public List getMyCompletedStudies() { Member currentMember = memberUtil.getCurrentMember(); List studyHistories = studyHistoryRepository.findAllByStudent(currentMember); List studyAchievements = studyAchievementRepository.findAllByStudent(currentMember); From 522a9727053827ec677a267f572cbfb5bdb8e0c5 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 21:16:24 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor:=20DTO=EC=97=90=EC=84=9C=20achie?= =?UTF-8?q?vement=20null=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/StudentStudyHistoryService.java | 4 ---- .../study/dto/response/StudentMyCompleteStudyResponse.java | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 1cfa3bca9..327e9e291 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -26,7 +26,6 @@ import com.gdschongik.gdsc.infra.github.client.GithubClient; import java.io.IOException; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -129,9 +128,6 @@ public List getMyCompletedStudies() { return studyHistories.stream() .map(history -> { List achievementTypes = achievementsByStudy.get(history.getStudy()); - if (achievementTypes == null) { - achievementTypes = new ArrayList<>(); - } return StudentMyCompleteStudyResponse.of(history, achievementTypes); }) .toList(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java index a77dbdab5..6362a91f4 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -5,6 +5,7 @@ import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.domain.study.domain.StudyHistoryStatus; import io.swagger.v3.oas.annotations.media.Schema; +import java.util.ArrayList; import java.util.List; public record StudentMyCompleteStudyResponse( @@ -32,6 +33,6 @@ public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List< studyHistory.getStudy().getMentor().getName(), studyHistory.getStudy().getTotalWeek(), studyHistory.getStudyHistoryStatus(), - achievements); + (achievements == null) ? new ArrayList<>() : achievements); } } From 6098f3a84b7bba74d41d187da6e21812a4ed190b Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 23:40:17 +0900 Subject: [PATCH 08/11] chore: import Collector --- .../study/application/StudentStudyHistoryService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 327e9e291..a45ae7e6f 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -1,6 +1,7 @@ package com.gdschongik.gdsc.domain.study.application; import static com.gdschongik.gdsc.global.exception.ErrorCode.*; +import static java.util.stream.Collectors.*; import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.dao.AssignmentHistoryRepository; @@ -29,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.kohsuke.github.GHRepository; @@ -121,9 +121,8 @@ public List getMyCompletedStudies() { List studyAchievements = studyAchievementRepository.findAllByStudent(currentMember); Map> achievementsByStudy = studyAchievements.stream() - .collect(Collectors.groupingBy( - StudyAchievement::getStudy, - Collectors.mapping(StudyAchievement::getAchievementType, Collectors.toList()))); + .collect(groupingBy( + StudyAchievement::getStudy, mapping(StudyAchievement::getAchievementType, toList()))); return studyHistories.stream() .map(history -> { From d56b660c01e771c6322da3395ba9dafd8d6218fc Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Sun, 6 Oct 2024 23:40:55 +0900 Subject: [PATCH 09/11] =?UTF-8?q?refactor:=20=EC=9A=B0=EC=88=98=20?= =?UTF-8?q?=EC=8A=A4=ED=84=B0=EB=94=94=EC=9B=90=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EC=9C=BC=EB=A9=B4=20null=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/dto/response/StudentMyCompleteStudyResponse.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java index 6362a91f4..55d70e71a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -5,7 +5,7 @@ import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.domain.study.domain.StudyHistoryStatus; import io.swagger.v3.oas.annotations.media.Schema; -import java.util.ArrayList; +import jakarta.annotation.Nullable; import java.util.List; public record StudentMyCompleteStudyResponse( @@ -19,7 +19,7 @@ public record StudentMyCompleteStudyResponse( @Schema(description = "멘토 이름") String mentorName, @Schema(description = "총 주차수") Long totalWeek, @Schema(description = "수료 여부") StudyHistoryStatus studyHistoryStatus, - @Schema(description = "우수 스터디원 여부") List achievements) { + @Nullable @Schema(description = "우수 스터디원 여부") List achievements) { public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List achievements) { return new StudentMyCompleteStudyResponse( @@ -33,6 +33,6 @@ public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List< studyHistory.getStudy().getMentor().getName(), studyHistory.getStudy().getTotalWeek(), studyHistory.getStudyHistoryStatus(), - (achievements == null) ? new ArrayList<>() : achievements); + achievements); } } From d998be5a715a535c2c7d8a080d061357a39381ab Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Wed, 9 Oct 2024 17:22:49 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor:=20=EC=9A=B0=EC=88=98=20?= =?UTF-8?q?=EC=8A=A4=ED=84=B0=EB=94=94=EC=9B=90=20=EC=84=A0=EC=A0=95=20?= =?UTF-8?q?=EB=82=B4=EC=97=AD=20=EA=B8=B0=EB=B3=B8=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/StudentStudyHistoryService.java | 4 +++- .../study/dto/response/StudentMyCompleteStudyResponse.java | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index a45ae7e6f..db39a9ac5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -27,6 +27,7 @@ import com.gdschongik.gdsc.infra.github.client.GithubClient; import java.io.IOException; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -126,7 +127,8 @@ public List getMyCompletedStudies() { return studyHistories.stream() .map(history -> { - List achievementTypes = achievementsByStudy.get(history.getStudy()); + List achievementTypes = + achievementsByStudy.getOrDefault(history.getStudy(), new ArrayList<>()); return StudentMyCompleteStudyResponse.of(history, achievementTypes); }) .toList(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java index 55d70e71a..a77dbdab5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -5,7 +5,6 @@ import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.domain.study.domain.StudyHistoryStatus; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.annotation.Nullable; import java.util.List; public record StudentMyCompleteStudyResponse( @@ -19,7 +18,7 @@ public record StudentMyCompleteStudyResponse( @Schema(description = "멘토 이름") String mentorName, @Schema(description = "총 주차수") Long totalWeek, @Schema(description = "수료 여부") StudyHistoryStatus studyHistoryStatus, - @Nullable @Schema(description = "우수 스터디원 여부") List achievements) { + @Schema(description = "우수 스터디원 여부") List achievements) { public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List achievements) { return new StudentMyCompleteStudyResponse( From 6d410630918e0638a48a69283af8e2f0416eca32 Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Wed, 9 Oct 2024 17:24:01 +0900 Subject: [PATCH 11/11] =?UTF-8?q?chore:=20=EC=9A=B0=EC=88=98=20=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=EC=9B=90=20=ED=95=84=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=EC=9B=A8=EA=B1=B0=20=EC=84=A4=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/dto/response/StudentMyCompleteStudyResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java index a77dbdab5..a7fa46d9a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCompleteStudyResponse.java @@ -18,7 +18,7 @@ public record StudentMyCompleteStudyResponse( @Schema(description = "멘토 이름") String mentorName, @Schema(description = "총 주차수") Long totalWeek, @Schema(description = "수료 여부") StudyHistoryStatus studyHistoryStatus, - @Schema(description = "우수 스터디원 여부") List achievements) { + @Schema(description = "우수 스터디원 선정 내역") List achievements) { public static StudentMyCompleteStudyResponse of(StudyHistory studyHistory, List achievements) { return new StudentMyCompleteStudyResponse(