Skip to content

Commit

Permalink
feat : 스터디 그룹 코드로 조회 시 방장 닉네임 추가 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
rladmstn authored Nov 15, 2024
1 parent 32aaa1c commit 563a0c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 563a0c3

Please sign in to comment.