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

활동 상세 조회 API 응답 수정 완료 #459

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
limehee marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import page.clab.api.domain.activity.activitygroup.dto.param.GroupScheduleDto;
import page.clab.api.domain.activity.activitygroup.dto.request.ApplyFormRequestDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupBoardResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupDetailResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupProjectResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupStatusResponseDto;
Expand Down Expand Up @@ -71,21 +72,15 @@ public Object getActivityGroup(Long activityGroupId) {
.map(groupMember -> GroupMemberResponseDto.toDto(externalRetrieveMemberUseCase.findByIdOrThrow(groupMember.getMemberId()), groupMember))
.toList();

List<ActivityGroupBoardResponseDto> activityGroupResponseDtos =
List<ActivityGroupBoardResponseDto> activityGroupBoardResponseDtos =
details.getActivityGroupBoards().stream()
.map(board -> {
MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getCurrentMemberBasicInfo();
return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto);
})
.toList();

if (details.getActivityGroup().isStudy()) {
return ActivityGroupStudyResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), activityGroupResponseDtos, groupMemberResponseDtos, isOwner);
} else if (details.getActivityGroup().isProject()) {
return ActivityGroupProjectResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), activityGroupResponseDtos, groupMemberResponseDtos, isOwner);
limehee marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw new InvalidCategoryException("해당 카테고리가 존재하지 않습니다.");
}
return ActivityGroupDetailResponseDto.create(details.getActivityGroup(), activityGroupBoardResponseDtos, groupMemberResponseDtos, isOwner);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package page.clab.api.domain.activity.activitygroup.dto.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Builder;
import lombok.Getter;
import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup;
import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory;
import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupStatus;
import page.clab.api.domain.activity.activitygroup.domain.GroupMember;

@Getter
@Builder
public class ActivityGroupDetailResponseDto {

private Long id;
private ActivityGroupCategory category;
private String subject;
private String name;
private String content;
private ActivityGroupStatus status;
private Long progress;
private String imageUrl;
private String curriculum;
private List<GroupMemberResponseDto> groupMembers;
private LocalDate startDate;
private LocalDate endDate;
private String techStack;
private String githubUrl;
private List<ActivityGroupBoardResponseDto> activityGroupBoards;

@JsonProperty("isOwner")
private boolean isOwner;
private LocalDateTime createdAt;

public static ActivityGroupDetailResponseDto create(ActivityGroup activityGroup,
List<ActivityGroupBoardResponseDto> boards, List<GroupMemberResponseDto> groupMemberResponseDtos, boolean isOwner) {
return ActivityGroupDetailResponseDto.builder()
.id(activityGroup.getId())
.category(activityGroup.getCategory())
.subject(activityGroup.getSubject())
.name(activityGroup.getName())
.content(activityGroup.getContent())
.status(activityGroup.getStatus())
.progress(activityGroup.getProgress())
.imageUrl(activityGroup.getImageUrl())
.curriculum(activityGroup.getCurriculum())
.groupMembers(groupMemberResponseDtos)
.startDate(activityGroup.getStartDate())
.endDate(activityGroup.getEndDate())
.techStack(activityGroup.getTechStack())
.githubUrl(activityGroup.getGithubUrl())
.activityGroupBoards(boards)
.isOwner(isOwner)
.createdAt(activityGroup.getCreatedAt())
.build();
}
}