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 : 그룹 초대 받은 목록, 보낸 목록 API 추가 #465

Merged
merged 10 commits into from
Jun 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import site.timecapsulearchive.core.domain.member_group.entity.MemberGroup;
import site.timecapsulearchive.core.domain.member_group.exception.MemberGroupNotFoundException;
import site.timecapsulearchive.core.domain.member_group.exception.NoGroupAuthorityException;
import site.timecapsulearchive.core.domain.member_group.repository.groupInviteRepository.GroupInviteRepository;
import site.timecapsulearchive.core.domain.member_group.repository.memberGroupRepository.MemberGroupRepository;
import site.timecapsulearchive.core.domain.member_group.repository.group_invite_repository.GroupInviteRepository;
import site.timecapsulearchive.core.domain.member_group.repository.member_group_repository.MemberGroupRepository;
import site.timecapsulearchive.core.global.error.ErrorCode;
import site.timecapsulearchive.core.infra.queue.manager.SocialNotificationManager;
import site.timecapsulearchive.core.infra.s3.manager.S3ObjectManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import java.time.ZonedDateTime;
import org.springframework.http.ResponseEntity;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupInviteSummaryResponses;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInvitesSliceResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesResponse;
import site.timecapsulearchive.core.global.common.response.ApiSpec;

public interface MemberGroupQueryApi {


@Operation(
summary = "그룹 요청 목록 조회",
description = "사용자애게 그룹 초대 요청이 온 그룹 목록을 조회한다.",
summary = "그룹 요청 받은 목록 조회",
description = "사용자에게 그룹 초대 요청이 온 모든 그룹 목록을 조회한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"member group"}
)
Expand All @@ -27,7 +28,7 @@ public interface MemberGroupQueryApi {
description = "ok"
)
})
ResponseEntity<ApiSpec<GroupInviteSummaryResponses>> findGroupInvites(
ResponseEntity<ApiSpec<GroupReceivingInvitesSliceResponse>> findGroupReceivingInvites(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true)
Expand Down Expand Up @@ -56,4 +57,22 @@ ResponseEntity<ApiSpec<GroupMemberInfosResponse>> findGroupMemberInfos(
Long groupId
);

@Operation(
summary = "그룹 요청 보낸 목록 조회",
description = "그룹장이 그룹 별로 그룹 초대 요청을 보낸 사용자 목록을 조회한다. 최대 30개가 반환된다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"member group"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "ok"
)
})
ResponseEntity<ApiSpec<GroupSendingInvitesResponse>> findGroupSendingInvites(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true)
Long groupId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberDto;
import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupInviteSummaryResponses;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInvitesSliceResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesResponse;
import site.timecapsulearchive.core.domain.member_group.service.MemberGroupQueryService;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
import site.timecapsulearchive.core.global.common.response.SuccessCode;
Expand All @@ -30,24 +32,24 @@ public class MemberGroupQueryApiController implements MemberGroupQueryApi {


@GetMapping(
value = "/invites",
value = "/receiving-invites",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<GroupInviteSummaryResponses>> findGroupInvites(
public ResponseEntity<ApiSpec<GroupReceivingInvitesSliceResponse>> findGroupReceivingInvites(
@AuthenticationPrincipal final Long memberId,
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<GroupInviteSummaryDto> groupInviteSummaryDtos = memberGroupQueryService.findGroupInvites(
final Slice<GroupInviteSummaryDto> groupReceivingInvitesSlice = memberGroupQueryService.findGroupReceivingInvitesSlice(
memberId, size, createdAt);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupInviteSummaryResponses.createOf(
groupInviteSummaryDtos.getContent(),
groupInviteSummaryDtos.hasNext(),
GroupReceivingInvitesSliceResponse.createOf(
groupReceivingInvitesSlice.getContent(),
groupReceivingInvitesSlice.hasNext(),
s3PreSignedUrlManager::getS3PreSignedUrlForGet
)
)
Expand Down Expand Up @@ -77,4 +79,23 @@ public ResponseEntity<ApiSpec<GroupMemberInfosResponse>> findGroupMemberInfos(
);
}

@GetMapping(
value = "/{group_id}/sending-invites",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<GroupSendingInvitesResponse>> findGroupSendingInvites(
@AuthenticationPrincipal final Long memberId,
@PathVariable(value = "group_id") final Long groupId
) {
List<GroupSendingInviteMemberDto> groupSendingInvites = memberGroupQueryService.findGroupSendingInvites(
memberId, groupId);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupSendingInvitesResponse.createOf(groupSendingInvites)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.time.ZonedDateTime;
import java.util.function.Function;
import lombok.Builder;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupInviteSummaryResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInviteSummaryResponse;

@Builder
public record GroupInviteSummaryDto(
Expand All @@ -12,19 +12,19 @@ public record GroupInviteSummaryDto(
String groupName,
String groupProfileUrl,
String description,
ZonedDateTime createdAt,
ZonedDateTime groupReceivingInviteTime,
String groupOwnerName
) {

public GroupInviteSummaryResponse toResponse(
public GroupReceivingInviteSummaryResponse toResponse(
final Function<String, String> preSignedUrlFunction
) {
return GroupInviteSummaryResponse.builder()
return GroupReceivingInviteSummaryResponse.builder()
.groupId(groupId)
.groupName(groupName)
.groupProfileUrl(preSignedUrlFunction.apply(groupProfileUrl))
.description(description)
.createdAt(createdAt)
.groupReceivingInviteTime(groupReceivingInviteTime)
.groupOwnerName(groupOwnerName)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package site.timecapsulearchive.core.domain.member_group.data.dto;


import java.time.ZonedDateTime;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInviteMemberResponse;

public record GroupSendingInviteMemberDto(
Long id,
String nickname,
String profileUrl,
ZonedDateTime sendingInvitesCreatedAt
) {

public GroupSendingInviteMemberResponse toResponse() {
return GroupSendingInviteMemberResponse.builder()
.id(id)
.nickname(nickname)
.profileUrl(profileUrl)
.sendingInvitesCreatedAt(sendingInvitesCreatedAt)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package site.timecapsulearchive.core.domain.member_group.data.dto;

import java.time.ZonedDateTime;

public record GroupSendingInvitesRequestDto(
Long memberId,
Long groupId,
int size,
ZonedDateTime createdAt
) {

public static GroupSendingInvitesRequestDto create(
final Long memberId,
final Long groupId,
final int size,
final ZonedDateTime createdAt
) {
return new GroupSendingInvitesRequestDto(memberId, groupId, size, createdAt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Builder
@Schema(description = "초대온 그룹 요약 정보")
public record GroupInviteSummaryResponse(
public record GroupReceivingInviteSummaryResponse(

@Schema(description = "그룹 아이디")
Long groupId,
Expand All @@ -21,16 +21,17 @@ public record GroupInviteSummaryResponse(
@Schema(description = "그룹 설명")
String description,

@Schema(description = "그룹 생성일")
ZonedDateTime createdAt,
@Schema(description = "그룹 초대 시간")
ZonedDateTime groupReceivingInviteTime,

@Schema(description = "그룹장")
String groupOwnerName
) {

public GroupInviteSummaryResponse {
if (createdAt != null) {
createdAt = createdAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID);
public GroupReceivingInviteSummaryResponse {
if (groupReceivingInviteTime != null) {
groupReceivingInviteTime = groupReceivingInviteTime.withZoneSameInstant(
ResponseMappingConstant.ZONE_ID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
import java.util.function.Function;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto;

public record GroupInviteSummaryResponses(
public record GroupReceivingInvitesSliceResponse(
@Schema(description = "초대 온 그룹 요약 정보 리스트")
List<GroupInviteSummaryResponse> responses,
List<GroupReceivingInviteSummaryResponse> responses,

@Schema(description = "다음 페이지 유무")
Boolean hasNext
) {

public static GroupInviteSummaryResponses createOf(
public static GroupReceivingInvitesSliceResponse createOf(
final List<GroupInviteSummaryDto> dtos,
final boolean hasNext,
final Function<String, String> preSignedUrlFunction
) {
List<GroupInviteSummaryResponse> groupInviteSummaryResponses = dtos.stream()
List<GroupReceivingInviteSummaryResponse> groupReceivingInviteSummaryResponse = dtos.stream()
.map(dto -> dto.toResponse(preSignedUrlFunction)).toList();

return new GroupInviteSummaryResponses(groupInviteSummaryResponses, hasNext);
return new GroupReceivingInvitesSliceResponse(groupReceivingInviteSummaryResponse,
hasNext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package site.timecapsulearchive.core.domain.member_group.data.response;

import java.time.ZonedDateTime;
import lombok.Builder;
import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant;

@Builder
public record GroupSendingInviteMemberResponse(
Long id,
String nickname,
String profileUrl,
ZonedDateTime sendingInvitesCreatedAt
) {
public GroupSendingInviteMemberResponse {
if (sendingInvitesCreatedAt != null) {
sendingInvitesCreatedAt = sendingInvitesCreatedAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package site.timecapsulearchive.core.domain.member_group.data.response;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto;

@Schema(description = "그룹 초대 보낸 목록")
public record GroupSendingInvitesResponse(

@Schema(description = "초대 보낸 그룹원 정보 리스트")
List<GroupSendingInviteMemberResponse> responses
) {

public static GroupSendingInvitesResponse createOf(
final List<GroupSendingInviteMemberDto> groupSendingInviteMemberDtos
) {
List<GroupSendingInviteMemberResponse> groupSendingInviteMemberResponses = groupSendingInviteMemberDtos.stream()
.map(GroupSendingInviteMemberDto::toResponse)
.toList();

return new GroupSendingInvitesResponse(groupSendingInviteMemberResponses);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package site.timecapsulearchive.core.domain.member_group.repository.groupInviteRepository;
package site.timecapsulearchive.core.domain.member_group.repository.group_invite_repository;

import java.time.ZonedDateTime;
import java.util.List;
import org.springframework.data.domain.Slice;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto;

public interface GroupInviteQueryRepository {

void bulkSave(final Long groupOwnerId, final Long groupId, final List<Long> groupMemberIds);

List<Long> findGroupInviteIdsByGroupIdAndGroupOwnerId(final Long groupId, final Long memberId);

Slice<GroupInviteSummaryDto> findGroupInvitesSummary(
Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
);

List<GroupSendingInviteMemberDto> findGroupSendingInvites(
final Long memberId,
final Long groupId
);
}
Loading
Loading