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 : 스터디 그룹 코드로 조회 시 방장 닉네임 추가 #178

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading