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 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 @@ -19,6 +19,7 @@
import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupStatus;
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.ActivityGroupDetailResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupStatusResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.GroupMemberResponseDto;
Expand Down Expand Up @@ -57,10 +58,10 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups
@Operation(summary = "[U] 활동 상세 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함")
@PreAuthorize("hasRole('USER')")
@GetMapping("/{activityGroupId}")
public ApiResponse<Object> getActivityGroup(
public ApiResponse<ActivityGroupDetailResponseDto> getActivityGroup(
@PathVariable(name = "activityGroupId") Long activityGroupId
) {
Object activityGroup = activityGroupMemberService.getActivityGroup(activityGroupId);
ActivityGroupDetailResponseDto activityGroup = activityGroupMemberService.getActivityGroup(activityGroupId);
return ApiResponse.success(activityGroup);
}

Expand Down
limehee marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
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.ActivityGroupProjectResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupDetailResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupStatusResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupStudyResponseDto;
import page.clab.api.domain.activity.activitygroup.dto.response.GroupMemberResponseDto;
import page.clab.api.domain.activity.activitygroup.exception.AlreadyAppliedException;
import page.clab.api.domain.activity.activitygroup.exception.InvalidCategoryException;
Expand Down Expand Up @@ -60,7 +59,7 @@ public PagedResponseDto<ActivityGroupResponseDto> getActivityGroups(Pageable pag
}

@Transactional(readOnly = true)
public Object getActivityGroup(Long activityGroupId) {
public ActivityGroupDetailResponseDto getActivityGroup(Long activityGroupId) {
ActivityGroupDetails details = activityGroupDetailsRepository.fetchActivityGroupDetails(activityGroupId);
Member currentMember = externalRetrieveMemberUseCase.getCurrentMember();

Expand All @@ -71,21 +70,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
@@ -1,29 +1,29 @@
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.ActivityGroupBoard;
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;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Getter
@Builder
public class ActivityGroupProjectResponseDto {
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;
Expand All @@ -35,16 +35,18 @@ public class ActivityGroupProjectResponseDto {
private boolean isOwner;
private LocalDateTime createdAt;

public static ActivityGroupProjectResponseDto create(ActivityGroup activityGroup, List<GroupMember> groupMembers,
public static ActivityGroupDetailResponseDto create(ActivityGroup activityGroup,
List<ActivityGroupBoardResponseDto> boards, List<GroupMemberResponseDto> groupMemberResponseDtos, boolean isOwner) {
return ActivityGroupProjectResponseDto.builder()
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())
Expand Down

This file was deleted.