Skip to content

Commit

Permalink
refact : 그룹 캡슐 공통 응답 DTO 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed Jun 8, 2024
1 parent 2e3d3a6 commit a7ad5f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleOpenStateDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleCreateRequest;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleUpdateRequest;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleDetailResponse;
Expand Down Expand Up @@ -121,7 +121,7 @@ public ResponseEntity<ApiSpec<MyGroupCapsuleSliceResponse>> getMyGroupCapsules(
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<MyGroupCapsuleDto> groupCapsules = groupCapsuleService.findMyGroupCapsuleSlice(
final Slice<CapsuleBasicInfoDto> groupCapsules = groupCapsuleService.findMyGroupCapsuleSlice(
memberId,
size,
createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import java.util.List;
import java.util.function.Function;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.data.response.CapsuleBasicInfoResponse;

public record MyGroupCapsuleSliceResponse(
List<MyGroupCapsuleResponse> groupCapsules,
List<CapsuleBasicInfoResponse> groupCapsules,
Boolean hasNext
) {

public static MyGroupCapsuleSliceResponse createOf(
final List<MyGroupCapsuleDto> groupCapsules,
final List<CapsuleBasicInfoDto> groupCapsules,
final boolean hasNext,
final Function<String, String> singlePreSignUrlFunction
) {
List<MyGroupCapsuleResponse> groupCapsuleResponses = groupCapsules.stream()
List<CapsuleBasicInfoResponse> groupCapsuleResponses = groupCapsules.stream()
.map(capsule -> capsule.toResponse(singlePreSignUrlFunction))
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.stereotype.Repository;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberSummaryDto;
import site.timecapsulearchive.core.domain.member.entity.QMember;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
Expand Down Expand Up @@ -131,15 +130,15 @@ public Optional<GroupCapsuleSummaryDto> findGroupCapsuleSummaryDtoByCapsuleId(
).get(capsuleId));
}

public Slice<MyGroupCapsuleDto> findMyGroupCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyGroupCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<MyGroupCapsuleDto> groupCapsules = jpaQueryFactory
final List<CapsuleBasicInfoDto> groupCapsules = jpaQueryFactory
.select(
Projections.constructor(
MyGroupCapsuleDto.class,
CapsuleBasicInfoDto.class,
capsule.id,
capsuleSkin.imageUrl,
capsule.dueDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.Capsule;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.exception.CapsuleNotFondException;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.repository.CapsuleRepository;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleCreateRequestDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleOpenStateDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.repository.GroupCapsuleQueryRepository;
import site.timecapsulearchive.core.domain.capsuleskin.entity.CapsuleSkin;
Expand Down Expand Up @@ -82,7 +82,7 @@ public GroupCapsuleSummaryDto findGroupCapsuleSummaryByGroupIDAndCapsuleId(
* @param createdAt 조회를 시작할 캡슐의 생성 시간, 첫 조회라면 현재 시간, 이후 조회라면 맨 마지막 데이터의 시간
* @return 사용자가 생성한 그룹 캡슐 목록
*/
public Slice<MyGroupCapsuleDto> findMyGroupCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyGroupCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
Expand Down

0 comments on commit a7ad5f1

Please sign in to comment.