diff --git a/src/main/java/com/gamzabat/algohub/feature/group/studygroup/dto/GetStudyGroupWithCodeResponse.java b/src/main/java/com/gamzabat/algohub/feature/group/studygroup/dto/GetStudyGroupWithCodeResponse.java index c8f411a0..2356275a 100644 --- a/src/main/java/com/gamzabat/algohub/feature/group/studygroup/dto/GetStudyGroupWithCodeResponse.java +++ b/src/main/java/com/gamzabat/algohub/feature/group/studygroup/dto/GetStudyGroupWithCodeResponse.java @@ -3,22 +3,25 @@ import java.time.LocalDate; import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup; +import com.gamzabat.algohub.feature.user.domain.User; public record GetStudyGroupWithCodeResponse(Long id, String name, String groupImage, LocalDate startDate, LocalDate endDate, - String introduction) { + String introduction, + String ownerNickname) { - public static GetStudyGroupWithCodeResponse toDTO(StudyGroup group) { + public static GetStudyGroupWithCodeResponse toDTO(StudyGroup group, User owner) { return new GetStudyGroupWithCodeResponse( group.getId(), group.getName(), group.getGroupImage(), group.getStartDate(), group.getEndDate(), - group.getIntroduction() + group.getIntroduction(), + owner.getNickname() ); } } diff --git a/src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java b/src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java index 390c3b22..47633a97 100644 --- a/src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java +++ b/src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java @@ -349,7 +349,8 @@ public GroupCodeResponse getGroupCode(User user, Long groupId) { public GetStudyGroupWithCodeResponse getGroupByCode(String code) { StudyGroup group = groupRepository.findByGroupCode(code) .orElseThrow(() -> new CannotFoundGroupException("그룹을 찾을 수 없습니다.")); - return GetStudyGroupWithCodeResponse.toDTO(group); + User owner = getStudyGroupOwner(group); + return GetStudyGroupWithCodeResponse.toDTO(group, owner); } @Transactional(readOnly = true)