Skip to content

Commit

Permalink
Merge pull request #491 from tukcomCD2024/fix/group_capsule-B-#490
Browse files Browse the repository at this point in the history
fix : 그룹 캡슐 요약 조회 api 수정 #490
  • Loading branch information
GaBaljaintheroom authored Jun 16, 2024
2 parents 752cbd3 + e33d2fd commit 84f03eb
Show file tree
Hide file tree
Showing 24 changed files with 790 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ ResponseEntity<ApiSpec<GroupCapsuleDetailResponse>> getGroupCapsuleDetailByCapsu
ResponseEntity<ApiSpec<GroupCapsuleSummaryResponse>> getGroupCapsuleSummaryByCapsuleId(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "그룹 아이디", required = true)
Long groupId,

@Parameter(in = ParameterIn.PATH, description = "조회할 캡슐 아이디", required = true)
Long capsuleId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
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.CombinedGroupCapsuleSummaryDto;
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.GroupCapsuleSliceRequestDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupMemberCapsuleOpenStatusDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleCreateRequest;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleUpdateRequest;
Expand Down Expand Up @@ -95,16 +95,20 @@ public ResponseEntity<ApiSpec<GroupCapsuleDetailResponse>> getGroupCapsuleDetail
@Override
public ResponseEntity<ApiSpec<GroupCapsuleSummaryResponse>> getGroupCapsuleSummaryByCapsuleId(
@AuthenticationPrincipal Long memberId,
@RequestParam("group_id") Long groupId,
@PathVariable("capsule_id") Long capsuleId
) {
final GroupCapsuleSummaryDto summaryDto = groupCapsuleService.findGroupCapsuleSummaryByGroupIDAndCapsuleId(
capsuleId);
CombinedGroupCapsuleSummaryDto groupCapsuleSummary = groupCapsuleService.findGroupCapsuleSummary(
memberId,
groupId,
capsuleId
);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupCapsuleSummaryResponse.createOf(
summaryDto,
groupCapsuleSummary,
s3PreSignedUrlManager::getS3PreSignedUrlForGet,
geoTransformManager::changePoint3857To4326
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.function.UnaryOperator;
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMemberResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSummaryResponse;

public record CombinedGroupCapsuleSummaryDto(
Long groupId,
String groupName,
String groupProfileUrl,
String creatorNickname,
String creatorProfileUrl,
String skinUrl,
String title,
ZonedDateTime dueDate,
Point point,
String address,
String roadName,
Boolean isCapsuleOpened,
ZonedDateTime createdAt,
Boolean isRequestMemberCapsuleOpen,
Boolean hasEditPermission,
Boolean hasDeletePermission,
List<GroupCapsuleMemberDto> groupMembers
) {

public static CombinedGroupCapsuleSummaryDto create(
final GroupCapsuleSummaryDto groupCapsuleSummaryDto,
final List<GroupCapsuleMemberDto> groupCapsuleMemberSummaryDtos,
final Boolean isRequestMemberCapsuleOpen,
final Boolean hasEditPermission,
final Boolean hasDeletePermission
) {
return new CombinedGroupCapsuleSummaryDto(
groupCapsuleSummaryDto.groupId(),
groupCapsuleSummaryDto.groupName(),
groupCapsuleSummaryDto.groupProfileUrl(),
groupCapsuleSummaryDto.creatorNickname(),
groupCapsuleSummaryDto.creatorProfileUrl(),
groupCapsuleSummaryDto.skinUrl(),
groupCapsuleSummaryDto.title(),
groupCapsuleSummaryDto.dueDate(),
groupCapsuleSummaryDto.point(),
groupCapsuleSummaryDto.address(),
groupCapsuleSummaryDto.roadName(),
groupCapsuleSummaryDto.isOpened(),
groupCapsuleSummaryDto.createdAt(),
isRequestMemberCapsuleOpen,
hasEditPermission,
hasDeletePermission,
groupCapsuleMemberSummaryDtos
);
}

public GroupCapsuleSummaryResponse toResponse(
final UnaryOperator<String> preSignUrlFunction,
final UnaryOperator<Point> changePointFunction
) {
final Point changePoint = changePointFunction.apply(point);

final List<GroupCapsuleMemberResponse> groupMembers = this.groupMembers.stream()
.map(GroupCapsuleMemberDto::toResponse)
.toList();

return GroupCapsuleSummaryResponse.builder()
.groupId(groupId)
.groupMembers(groupMembers)
.groupName(groupName)
.groupProfileUrl(preSignUrlFunction.apply(groupProfileUrl))
.creatorNickname(creatorNickname)
.creatorProfileUrl(creatorProfileUrl)
.skinUrl(preSignUrlFunction.apply(skinUrl))
.title(title)
.dueDate(dueDate)
.latitude(changePoint.getX())
.longitude(changePoint.getY())
.address(address)
.roadName(roadName)
.isCapsuleOpened(isCapsuleOpened)
.isRequestMemberCapsuleOpened(isRequestMemberCapsuleOpen)
.hasEditPermission(hasEditPermission)
.hasDeletePermission(hasDeletePermission)
.createdAt(createdAt)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleDetailResponse;
import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberSummaryDto;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberSummaryResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMemberSummaryResponse;

public record GroupCapsuleDetailDto(
CapsuleDetailDto capsuleDetailDto,
List<GroupMemberSummaryDto> members
List<GroupCapsuleMemberSummaryDto> members
) {

public List<GroupMemberSummaryResponse> groupMemberSummaryDtoToResponse() {
public List<GroupCapsuleMemberSummaryResponse> groupMemberSummaryDtoToResponse() {
return members.stream()
.map(GroupMemberSummaryDto::toResponse)
.map(GroupCapsuleMemberSummaryDto::toResponse)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto;

import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMemberResponse;

public record GroupCapsuleMemberDto(
Long id,
String nickname,
String profileUrl,
Boolean isGroupOwner,
Boolean isOpened
) {

public GroupCapsuleMemberResponse toResponse() {
return new GroupCapsuleMemberResponse(id, nickname, profileUrl, isGroupOwner, isOpened);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto;

import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMemberSummaryResponse;

public record GroupCapsuleMemberSummaryDto(
String nickname,
String profileUrl,
Boolean isOpened
) {

public GroupCapsuleMemberSummaryResponse toResponse() {
return new GroupCapsuleMemberSummaryResponse(nickname, profileUrl, isOpened);
}
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto;

import java.util.List;
import java.util.function.Function;
import java.time.ZonedDateTime;
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSummaryResponse;
import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberSummaryDto;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberSummaryResponse;

public record GroupCapsuleSummaryDto(
CapsuleSummaryDto capsuleSummaryDto,
List<GroupMemberSummaryDto> members
Long groupId,
String groupName,
String groupProfileUrl,
Long creatorId,
String creatorNickname,
String creatorProfileUrl,
String skinUrl,
String title,
ZonedDateTime dueDate,
Point point,
String address,
String roadName,
Boolean isOpened,
ZonedDateTime createdAt
) {

public List<GroupMemberSummaryResponse> groupMemberSummaryDtoToResponse() {
return members.stream()
.map(GroupMemberSummaryDto::toResponse)
.toList();
}

public GroupCapsuleSummaryResponse toResponse(
final Function<String, String> preSignUrlFunction,
final Function<Point, Point> changePointFunction
) {
final Point changePoint = changePointFunction.apply(capsuleSummaryDto.point());

return GroupCapsuleSummaryResponse.builder()
.members(groupMemberSummaryDtoToResponse())
.nickname(capsuleSummaryDto.nickname())
.profileUrl(capsuleSummaryDto.profileUrl())
.skinUrl(preSignUrlFunction.apply(capsuleSummaryDto.skinUrl()))
.title(capsuleSummaryDto.title())
.dueDate(capsuleSummaryDto.dueDate())
.latitude(changePoint.getX())
.longitude(changePoint.getY())
.address(capsuleSummaryDto.address())
.roadName(capsuleSummaryDto.roadName())
.isOpened(capsuleSummaryDto.isOpened())
.createdAt(capsuleSummaryDto.createdAt())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberSummaryResponse;
import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant;

@Schema(description = "그룹 캡슐 상세 정보")
@Builder
public record GroupCapsuleDetailResponse(

@Schema(description = "캡슐 아이디")
Long capsuleId,

@Schema(description = "캡슐 스킨 url")
String capsuleSkinUrl,

@Schema(description = "그룹원 요약 정보")
List<GroupMemberSummaryResponse> members,
List<GroupCapsuleMemberSummaryResponse> members,

@Schema(description = "개봉일")
ZonedDateTime dueDate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.response;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "그룹원 요약 정보")
public record GroupCapsuleMemberResponse(

@Schema(description = "사용자 아이디")
Long id,

@Schema(description = "닉네임")
String nickname,

@Schema(description = "프로필 url")
String profileUrl,

@Schema(description = "그룹장 여부")
Boolean isGroupOwner,

@Schema(description = "개봉 여부")
Boolean isOpened
) {

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package site.timecapsulearchive.core.domain.group.data.response;
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.response;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "그룹원 요약 정보")
public record GroupMemberSummaryResponse(
public record GroupCapsuleMemberSummaryResponse(

@Schema(description = "닉네임")
String nickname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import lombok.Builder;
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberSummaryResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.CombinedGroupCapsuleSummaryDto;
import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant;

@Schema(description = "캡슐 요약 정보")
@Builder
public record GroupCapsuleSummaryResponse(

@Schema(description = "그룹 아이디")
Long groupId,

@Schema(description = "그룹원 요약 정보")
List<GroupMemberSummaryResponse> members,
List<GroupCapsuleMemberResponse> groupMembers,

@Schema(description = "그룹 이름")
String groupName,

@Schema(description = "그룹 프로필 url")
String groupProfileUrl,

@Schema(description = "생성자 닉네임")
String nickname,
String creatorNickname,

@Schema(description = "생성자 프로필 url")
String profileUrl,
String creatorProfileUrl,

@Schema(description = "캡슐 스킨 url")
String skinUrl,
Expand All @@ -44,8 +52,17 @@ public record GroupCapsuleSummaryResponse(
@Schema(description = "캡슐 생성 도로 이름")
String roadName,

@Schema(description = "개봉 여부")
Boolean isOpened,
@Schema(description = "캡슐 개봉 여부")
Boolean isCapsuleOpened,

@Schema(description = "현재 사용자 캡슐 개봉 여부")
Boolean isRequestMemberCapsuleOpened,

@Schema(description = "캡슐 수정 권한 여부")
Boolean hasEditPermission,

@Schema(description = "캡슐 삭제 권한 여부")
Boolean hasDeletePermission,

@Schema(description = "캡슐 생성 일")
ZonedDateTime createdAt
Expand All @@ -60,10 +77,10 @@ public record GroupCapsuleSummaryResponse(
}

public static GroupCapsuleSummaryResponse createOf(
final GroupCapsuleSummaryDto summaryDto,
final Function<String, String> preSignUrlFunction,
final Function<Point, Point> changePointFunction
final CombinedGroupCapsuleSummaryDto groupCapsuleSummary,
final UnaryOperator<String> preSignUrlFunction,
final UnaryOperator<Point> changePointFunction
) {
return summaryDto.toResponse(preSignUrlFunction, changePointFunction);
return groupCapsuleSummary.toResponse(preSignUrlFunction, changePointFunction);
}
}
Loading

0 comments on commit 84f03eb

Please sign in to comment.