Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat/group_invite_list-B-#458' into feat/fri…
Browse files Browse the repository at this point in the history
…end_invite_delete-B-#457

# Conflicts:
#	backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepository.java
#	backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryImpl.java
#	backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/command/FriendCommandService.java
#	backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryTest.java
  • Loading branch information
seokho-1116 committed Jun 4, 2024
2 parents 041cac8 + 69d0cf6 commit 0e81253
Show file tree
Hide file tree
Showing 76 changed files with 1,517 additions and 416 deletions.
2 changes: 2 additions & 0 deletions backend/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {
//redis
implementation 'org.springframework.data:spring-data-redis'
implementation 'io.lettuce:lettuce-core:6.3.0.RELEASE'
implementation 'org.redisson:redisson-spring-boot-starter:3.30.0'

//RabbitMQ
implementation 'org.springframework.boot:spring-boot-starter-amqp'
Expand Down Expand Up @@ -85,6 +86,7 @@ dependencies {
testImplementation 'org.testcontainers:testcontainers:1.19.1'
testImplementation 'org.testcontainers:junit-jupiter:1.19.1'
testImplementation 'org.testcontainers:mysql:1.19.1'
testImplementation 'com.redis:testcontainers-redis:2.2.2'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@Builder
public record GroupCapsuleCreateRequestDto(
List<Long> groupMemberIds,
List<String> imageNames,
List<String> videoNames,
Long capsuleSkinId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
@Schema(description = "그룹 캡슐 생성 포맷")
public record GroupCapsuleCreateRequest(

@Schema(description = "그룹 멤버 아이디들")
@NotNull(message = "그룹 멤버 아이디들는 필수입니다.")
List<Long> groupMemberIds,

@Schema(description = "업로드한 이미지 경로 ex) xxx.jpg")
List<@Image String> imageNames,

Expand Down Expand Up @@ -56,7 +52,6 @@ public record GroupCapsuleCreateRequest(

public GroupCapsuleCreateRequestDto toGroupCapsuleCreateRequestDto() {
return GroupCapsuleCreateRequestDto.builder()
.groupMemberIds(groupMemberIds)
.videoNames(videoNames)
.imageNames(imageNames)
.capsuleSkinId(capsuleSkinId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.facade;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.locationtech.jts.geom.Point;
import org.springframework.stereotype.Component;
Expand All @@ -16,6 +17,7 @@
import site.timecapsulearchive.core.domain.group.service.query.GroupQueryService;
import site.timecapsulearchive.core.domain.member.entity.Member;
import site.timecapsulearchive.core.domain.member.service.MemberService;
import site.timecapsulearchive.core.domain.member_group.service.MemberGroupQueryService;
import site.timecapsulearchive.core.global.geography.GeoTransformManager;

@Component
Expand All @@ -25,6 +27,7 @@ public class GroupCapsuleFacade {
private final MemberService memberService;
private final GroupCapsuleService groupCapsuleService;
private final GroupQueryService groupQueryService;
private final MemberGroupQueryService memberGroupQueryService;
private final ImageService imageService;
private final VideoService videoService;
private final GeoTransformManager geoTransformManager;
Expand All @@ -51,6 +54,8 @@ public void saveGroupCapsule(
imageService.bulkSave(dto.imageNames(), capsule, member);
videoService.bulkSave(dto.videoNames(), capsule, member);

groupCapsuleOpenService.bulkSave(dto.groupMemberIds(), capsule);
final List<Long> groupMemberIds = memberGroupQueryService.findGroupMemberIds(groupId);

groupCapsuleOpenService.bulkSave(groupMemberIds, capsule);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import site.timecapsulearchive.core.domain.capsuleskin.data.dto.CapsuleSkinCreateDto;
import site.timecapsulearchive.core.domain.capsuleskin.data.dto.CapsuleSkinSummaryDto;
Expand Down Expand Up @@ -59,12 +57,9 @@ public CapsuleSkinStatusResponse sendCapsuleSkinCreateMessage(
if (isNotExistMotionNameAndRetarget(dto)) {
CapsuleSkin capsuleSkin = capsuleSkinMapper.createDtoToEntity(dto, foundMember);

transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
capsuleSkinRepository.save(capsuleSkin);
}
});
transactionTemplate.executeWithoutResult(status ->
capsuleSkinRepository.save(capsuleSkin)
);
return CapsuleSkinStatusResponse.success();
}

Expand Down
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 Expand Up @@ -106,10 +131,10 @@ ResponseEntity<ApiSpec<SearchFriendsResponse>> searchMembersByPhones(
@Operation(
summary = "친구 검색",
description = """
친구의 tag로 친구 검색을 한다.
<br>
태그가 일치하면 일치하는 태그를 가진 사용자를 일치하지 않으면 가장 비슷한 태그를 가진 사용자를 반환한다.
""",
친구의 tag로 친구 검색을 한다.
<br>
태그가 일치하면 일치하는 태그를 가진 사용자를 일치하지 않으면 가장 비슷한 태그를 가진 사용자를 반환한다.
""",
security = {@SecurityRequirement(name = "user_token")},
tags = {"friend"}
)
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,14 +1,32 @@
package site.timecapsulearchive.core.domain.friend.repository.friend_invite;

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

public interface FriendInviteQueryRepository {

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

List<FriendInviteMemberIdsDto> findFriendInviteMemberIdsDtoByMemberIdsAndFriendId(List<Long> memberIds, Long friendId);

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

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

List<FriendInviteMemberIdsDto> findFriendInviteMemberIdsDtoByMemberIdsAndFriendId(
List<Long> memberIds, Long friendId);

Optional<FriendInviteMemberIdsDto> findFriendInviteMemberIdsDtoByMemberIdAndFriendId(
Long memberId, Long friendId);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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.BooleanBuilder;
import com.querydsl.core.types.Projections;
Expand All @@ -11,12 +12,13 @@
import java.sql.Types;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Slice;
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.FriendInviteMemberIdsDto;
import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
Expand Down Expand Up @@ -56,6 +58,55 @@ 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);
}

@Override
public List<FriendInviteMemberIdsDto> findFriendInviteMemberIdsDtoByMemberIdsAndFriendId(
List<Long> memberIds, Long friendId) {
Expand Down
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
Loading

0 comments on commit 0e81253

Please sign in to comment.