Skip to content

Commit

Permalink
Merge branch 'develop_back_core' of https://github.com/tukcomCD2024/D…
Browse files Browse the repository at this point in the history
…roidBlossom into develop_back_core
  • Loading branch information
GaBaljaintheroom committed Jun 5, 2024
2 parents b607f09 + a39dfc6 commit 384c8d4
Show file tree
Hide file tree
Showing 35 changed files with 685 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.time.ZonedDateTime;
import org.springframework.http.ResponseEntity;
import site.timecapsulearchive.core.domain.friend.data.request.SearchFriendsRequest;
import site.timecapsulearchive.core.domain.friend.data.response.FriendRequestsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchFriendsResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchTagFriendSummaryResponse;
Expand Down Expand Up @@ -65,8 +64,34 @@ ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendsBeforeGroupInvite(
);

@Operation(
summary = "소셜 친구 요청 목록 조회",
description = "사용자의 소셜 친구 요청 목록을 보여준다. 수락 대기 중인 요청만 해당한다.",
summary = "소셜 친구 요청 받은 목록 조회",
description = """
사용자가 <b><u>소셜 친구 요청을 받은 목록</u></b>을 보여준다.
<br>
수락 대기 중인 요청만 해당한다.
""",
security = {@SecurityRequirement(name = "user_token")},
tags = {"friend"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "ok"
)
})
ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendReceivingInvites(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true)
int size,

@Parameter(in = ParameterIn.QUERY, description = "마지막 데이터의 시간", required = true)
ZonedDateTime createdAt
);

@Operation(
summary = "소셜 친구 요청 보낸 목록 조회",
description = "사용자가 <b><u>소셜 친구 요청을 보낸 목록</u></b>을 보여준다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"friend"}
)
Expand All @@ -76,7 +101,7 @@ ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendsBeforeGroupInvite(
description = "ok"
)
})
ResponseEntity<ApiSpec<FriendRequestsSliceResponse>> findFriendRequests(
ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendSendingInvites(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag;
import site.timecapsulearchive.core.domain.friend.data.request.FriendBeforeGroupInviteRequest;
import site.timecapsulearchive.core.domain.friend.data.request.SearchFriendsRequest;
import site.timecapsulearchive.core.domain.friend.data.response.FriendRequestsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchFriendsResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchTagFriendSummaryResponse;
Expand Down Expand Up @@ -77,23 +76,45 @@ public ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendsBeforeGroupInvit
}

@GetMapping(
value = "/requests",
value = "/receiving-invites",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<FriendRequestsSliceResponse>> findFriendRequests(
public ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendReceivingInvites(
@AuthenticationPrincipal final Long memberId,
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<FriendSummaryDto> friendRequestsSlice = friendQueryService.findFriendRequestsSlice(
final Slice<FriendSummaryDto> friendReceivingInvitesSlice = friendQueryService.findFriendReceivingInvitesSlice(
memberId, size, createdAt);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
FriendRequestsSliceResponse.createOf(friendRequestsSlice.getContent(),
friendRequestsSlice.hasNext())
FriendsSliceResponse.createOf(friendReceivingInvitesSlice.getContent(),
friendReceivingInvitesSlice.hasNext())
)
);
}

@GetMapping(
value = "/sending-invites",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<FriendsSliceResponse>> findFriendSendingInvites(
@AuthenticationPrincipal final Long memberId,
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<FriendSummaryDto> friendSendingInvitesSlice = friendQueryService.findFriendSendingInvitesSlice(
memberId, size, createdAt);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
FriendsSliceResponse.createOf(friendSendingInvitesSlice.getContent(),
friendSendingInvitesSlice.hasNext())
)
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
package site.timecapsulearchive.core.domain.friend.repository.friend_invite;

import java.time.ZonedDateTime;
import java.util.List;
import org.springframework.data.domain.Slice;
import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto;

public interface FriendInviteQueryRepository {

void bulkSave(final Long ownerId, final List<Long> friendIds);


Slice<FriendSummaryDto> findFriendReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
);

Slice<FriendSummaryDto> findFriendSendingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
);
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
package site.timecapsulearchive.core.domain.friend.repository.friend_invite;

import static site.timecapsulearchive.core.domain.friend.entity.QFriendInvite.friendInvite;
import static site.timecapsulearchive.core.domain.member.entity.QMember.member;

import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
public class FriendInviteQueryRepositoryImpl implements FriendInviteQueryRepository {

private final JdbcTemplate jdbcTemplate;
private final JPAQueryFactory jpaQueryFactory;

public void bulkSave(final Long ownerId, final List<Long> friendIds) {
if (friendIds.isEmpty()) {
Expand Down Expand Up @@ -47,4 +58,53 @@ public int getBatchSize() {
}
);
}

public Slice<FriendSummaryDto> findFriendReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<FriendSummaryDto> friends = jpaQueryFactory
.select(
Projections.constructor(
FriendSummaryDto.class,
friendInvite.owner.id,
friendInvite.owner.profileUrl,
friendInvite.owner.nickname,
friendInvite.createdAt
)
)
.from(friendInvite)
.join(friendInvite.owner, member)
.where(friendInvite.friend.id.eq(memberId).and(friendInvite.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();

return SliceUtil.makeSlice(size, friends);
}

@Override
public Slice<FriendSummaryDto> findFriendSendingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<FriendSummaryDto> friends = jpaQueryFactory
.select(
Projections.constructor(
FriendSummaryDto.class,
friendInvite.friend.id,
friendInvite.friend.profileUrl,
friendInvite.friend.nickname,
friendInvite.createdAt
)
)
.from(friendInvite)
.join(friendInvite.owner, member)
.where(friendInvite.owner.id.eq(memberId).and(friendInvite.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();

return SliceUtil.makeSlice(size, friends);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ Slice<FriendSummaryDto> findFriendsSlice(
final ZonedDateTime createdAt
);

Slice<FriendSummaryDto> findFriendRequestsSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
);

List<SearchFriendSummaryDto> findFriendsByPhone(
final Long memberId,
final List<byte[]> hashes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,6 @@ public Slice<FriendSummaryDto> findFriendsBeforeGroupInvite(
return getFriendSummaryDtos(request.size(), friends);
}

public Slice<FriendSummaryDto> findFriendRequestsSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<FriendSummaryDto> friends = jpaQueryFactory
.select(
Projections.constructor(
FriendSummaryDto.class,
friendInvite.owner.id,
friendInvite.owner.profileUrl,
friendInvite.owner.nickname,
friendInvite.createdAt
)
)
.from(friendInvite)
.join(friendInvite.owner, member)
.where(friendInvite.friend.id.eq(memberId).and(friendInvite.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();

return getFriendSummaryDtos(size, friends);
}

public List<SearchFriendSummaryDto> findFriendsByPhone(
final Long memberId,
final List<byte[]> hashes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag;
import site.timecapsulearchive.core.domain.friend.data.request.FriendBeforeGroupInviteRequest;
import site.timecapsulearchive.core.domain.friend.exception.FriendNotFoundException;
import site.timecapsulearchive.core.domain.friend.repository.friend_invite.FriendInviteRepository;
import site.timecapsulearchive.core.domain.friend.repository.member_friend.MemberFriendRepository;
import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper;

Expand All @@ -20,6 +21,7 @@
public class FriendQueryService {

private final MemberFriendRepository memberFriendRepository;
private final FriendInviteRepository friendInviteRepository;

public Slice<FriendSummaryDto> findFriendsSlice(
final Long memberId,
Expand All @@ -34,12 +36,20 @@ public Slice<FriendSummaryDto> findFriendsBeforeGroupInviteSlice(
return memberFriendRepository.findFriendsBeforeGroupInvite(request);
}

public Slice<FriendSummaryDto> findFriendRequestsSlice(
public Slice<FriendSummaryDto> findFriendReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
return memberFriendRepository.findFriendRequestsSlice(memberId, size, createdAt);
return friendInviteRepository.findFriendReceivingInvitesSlice(memberId, size, createdAt);
}

public Slice<FriendSummaryDto> findFriendSendingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
return friendInviteRepository.findFriendSendingInvitesSlice(memberId, size, createdAt);
}

public List<SearchFriendSummaryDto> findFriendsByPhone(
Expand Down
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
);
}
Loading

0 comments on commit 384c8d4

Please sign in to comment.