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

fix : querydsl join문 softdelete where 절 추가 문제 해결 #603

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import site.timecapsulearchive.core.global.common.response.ApiSpec;

public interface AnnouncementApi {

@Operation(
summary = "공지사항 페이지",
description = "모든 공지사항을 가져온다. 최신 공지가 리스트의 맨 처음에 위치한다.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.timecapsulearchive.core.domain.announcement.data.response.AnnouncementsResponse;
import site.timecapsulearchive.core.domain.announcement.data.dto.AnnouncementDto;
import site.timecapsulearchive.core.domain.announcement.data.response.AnnouncementsResponse;
import site.timecapsulearchive.core.domain.announcement.service.AnnouncementService;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
import site.timecapsulearchive.core.global.common.response.SuccessCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public List<NearbyARCapsuleSummaryDto> findARCapsuleSummaryDtosByCurrentLocation
)
)
.from(capsule)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.member, member)
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.where(
ST_Contains(mbr, capsule.point).and(capsuleFilter(capsuleType, memberId, groupIds)))
.fetch();
Expand Down Expand Up @@ -114,8 +115,6 @@ public List<NearbyCapsuleSummaryDto> findCapsuleSummaryDtosByCurrentLocationAndC
)
)
.from(capsule)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.member, member)
.where(
ST_Contains(mbr, capsule.point).and(capsuleFilter(capsuleType, memberId, groupIds)))
.fetch();
Expand Down Expand Up @@ -143,8 +142,6 @@ public List<NearbyCapsuleSummaryDto> findFriendsCapsuleSummaryDtosByCurrentLocat
)
)
.from(capsule)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.member, member)
.where(ST_Contains(mbr, capsule.point).and(capsule.member.id.in(friendIds))
.and(capsule.type.eq(CapsuleType.PUBLIC)))
.fetch();
Expand Down Expand Up @@ -181,8 +178,9 @@ public List<NearbyARCapsuleSummaryDto> findFriendsARCapsulesByCurrentLocation(
)
)
.from(capsule)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.member, member)
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.where(ST_Contains(mbr, capsule.point).and(capsule.member.id.in(friendIds))
.and(capsule.type.eq(CapsuleType.PUBLIC)))
.fetch();
Expand All @@ -201,7 +199,8 @@ public Optional<TreasureCapsuleSummaryDto> findTreasureCapsuleSummary(final Long
)
)
.from(capsule)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.where(capsule.id.eq(capsuleId))
.fetchOne()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ public List<GroupCapsuleMemberDto> findGroupCapsuleMembers(
)
)
.from(groupCapsuleOpen)
.join(memberGroup).on(groupCapsuleOpen.member.id.eq(memberGroup.member.id))
.join(groupCapsuleOpen.member, member)
.join(memberGroup)
.on(groupCapsuleOpen.member.eq(memberGroup.member), memberGroup.deletedAt.isNull())
.join(member).on(groupCapsuleOpen.member.eq(member), member.deletedAt.isNull())
.where(groupCapsuleOpen.group.id.eq(groupId)
.and(groupCapsuleOpen.capsule.id.eq(capsuleId))
.and(memberGroup.group.id.eq(groupId))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.repository;

import static com.querydsl.core.group.GroupBy.groupBy;
import static site.timecapsulearchive.core.domain.capsule.entity.QCapsule.capsule;
import static site.timecapsulearchive.core.domain.capsule.entity.QGroupCapsuleOpen.groupCapsuleOpen;
import static site.timecapsulearchive.core.domain.capsule.entity.QImage.image;
import static site.timecapsulearchive.core.domain.capsule.entity.QVideo.video;
import static site.timecapsulearchive.core.domain.capsuleskin.entity.QCapsuleSkin.capsuleSkin;
Expand All @@ -26,7 +24,6 @@
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupSpecificCapsuleSliceRequestDto;
import site.timecapsulearchive.core.domain.member.entity.QMember;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
Expand Down Expand Up @@ -63,10 +60,11 @@ public Optional<GroupCapsuleDetailDto> findGroupCapsuleDetailDtoByCapsuleId(
)
.from(capsule)
.join(capsule.member, member)
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.join(capsule.group, group)
.leftJoin(image).on(capsule.id.eq(image.capsule.id))
.leftJoin(video).on(capsule.id.eq(video.capsule.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(group).on(capsule.group.eq(group), group.deletedAt.isNull())
.leftJoin(image).on(capsule.eq(image.capsule), image.deletedAt.isNull())
.leftJoin(video).on(capsule.eq(video.capsule), video.deletedAt.isNull())
.where(capsule.id.eq(capsuleId).and(capsule.type.eq(CapsuleType.GROUP)))
.fetchOne()
);
Expand Down Expand Up @@ -101,9 +99,10 @@ public Optional<GroupCapsuleSummaryDto> findGroupCapsuleSummaryDtoByCapsuleId(
)
)
.from(capsule)
.join(capsule.member, member)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.group, group)
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.join(group).on(capsule.group.eq(group), group.deletedAt.isNull())
.where(capsule.id.eq(capsuleId)
.and(capsule.type.eq(CapsuleType.GROUP))
)
Expand All @@ -130,8 +129,9 @@ public Slice<CapsuleBasicInfoDto> findMyGroupCapsuleSlice(
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.where(capsule.member.id.eq(memberId)
.and(capsule.createdAt.lt(createdAt))
.and(capsule.type.eq(CapsuleType.GROUP)))
Expand Down Expand Up @@ -222,11 +222,12 @@ public Slice<GroupCapsuleDto> findGroupCapsuleSlice(
)
)
.from(capsule)
.join(capsule.member, member)
.join(capsule.capsuleSkin, capsuleSkin)
.join(capsule.group, group)
.leftJoin(image).on(capsule.id.eq(image.capsule.id))
.leftJoin(video).on(capsule.id.eq(video.capsule.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.join(group).on(capsule.group.eq(group), group.deletedAt.isNull())
.leftJoin(image).on(capsule.eq(image.capsule), image.deletedAt.isNull())
.leftJoin(video).on(capsule.eq(video.capsule), video.deletedAt.isNull())
.where(capsule.type.eq(CapsuleType.GROUP)
.and(capsule.group.id.in(groupIds))
.and(capsuleIdPagingCursorCondition(lastCapsuleId)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ public Optional<PublicCapsuleDetailDto> findPublicCapsuleDetailDtosByMemberIdAnd
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.leftJoin(memberFriend).on(capsule.member.id.eq(memberFriend.owner.id)
.or(capsule.member.id.eq(memberFriend.friend.id)))
.leftJoin(image).on(capsule.id.eq(image.capsule.id))
.leftJoin(video).on(capsule.id.eq(video.capsule.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.leftJoin(memberFriend).on(capsule.member.eq(memberFriend.owner)
.or(capsule.member.eq(memberFriend.friend)), memberFriend.deletedAt.isNull())
.leftJoin(image).on(capsule.eq(image.capsule), image.deletedAt.isNull())
.leftJoin(video).on(capsule.eq(video.capsule), video.deletedAt.isNull())
.where(capsule.id.eq(capsuleId).and(capsule.type.eq(CapsuleType.PUBLIC))
.and(eqMemberIdOrFriendId(memberId)))
.fetchFirst();
Expand Down Expand Up @@ -118,10 +119,11 @@ public Optional<PublicCapsuleSummaryDto> findPublicCapsuleSummaryDtosByMemberIdA
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.leftJoin(memberFriend).on(capsule.member.id.eq(memberFriend.owner.id)
.or(capsule.member.id.eq(memberFriend.friend.id)))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.leftJoin(memberFriend).on(capsule.member.eq(memberFriend.owner)
.or(capsule.member.eq(memberFriend.friend)), memberFriend.deletedAt.isNull())
.where(capsule.id.eq(capsuleId).and(capsule.type.eq(CapsuleType.PUBLIC))
.and(eqMemberIdOrFriendId(memberId)))
.groupBy(capsule.id)
Expand Down Expand Up @@ -167,10 +169,11 @@ public Slice<PublicCapsuleDetailDto> findPublicCapsulesDtoMadeByFriend(
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.leftJoin(image).on(capsule.id.eq(image.capsule.id))
.leftJoin(video).on(capsule.id.eq(video.capsule.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.leftJoin(image).on(capsule.eq(image.capsule), image.deletedAt.isNull())
.leftJoin(video).on(capsule.eq(video.capsule), video.deletedAt.isNull())
.where(capsule.member.id.in(memberIds)
.and(capsule.createdAt.lt(createdAt))
.and(capsule.type.eq(CapsuleType.PUBLIC)))
Expand Down Expand Up @@ -202,8 +205,9 @@ public Slice<CapsuleBasicInfoDto> findMyPublicCapsuleSlice(
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.where(capsule.member.id.eq(memberId)
.and(capsule.createdAt.lt(createdAt))
.and(capsule.type.eq(CapsuleType.PUBLIC)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public Optional<CapsuleDetailDto> findSecretCapsuleDetailDtosByMemberIdAndCapsul
)
)
.from(capsule)
.join(member).on(capsule.member.id.eq(member.id))
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.leftJoin(image).on(capsule.id.eq(image.capsule.id))
.leftJoin(video).on(capsule.id.eq(video.capsule.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.join(member).on(capsule.member.eq(member), member.deletedAt.isNull())
.leftJoin(image).on(capsule.eq(image.capsule), image.deletedAt.isNull())
.leftJoin(video).on(capsule.eq(video.capsule), video.deletedAt.isNull())
.where(
capsule.id.eq(capsuleId)
.and(capsule.member.id.eq(memberId))
Expand Down Expand Up @@ -122,7 +123,8 @@ public Slice<CapsuleBasicInfoDto> findSecretCapsuleSliceByMemberIdAndCreatedAt(
)
)
.from(capsule)
.join(capsuleSkin).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.join(capsuleSkin)
.on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.where(
capsule.member.id.eq(memberId),
capsule.createdAt.lt(createdAt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public record CapsuleSkinDeleteResultDto(
) {

public static CapsuleSkinDeleteResultDto fail() {
return new CapsuleSkinDeleteResultDto(CapsuleSkinDeleteResult.FAIL, "캡슐 스킨이 존재하지 않거나 캡슐에 사용되고 있습니다.");
return new CapsuleSkinDeleteResultDto(CapsuleSkinDeleteResult.FAIL,
"캡슐 스킨이 존재하지 않거나 캡슐에 사용되고 있습니다.");
}

public static CapsuleSkinDeleteResultDto success() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean existRelatedCapsule(final Long memberId, final Long capsuleSkinId
Integer count = jpaQueryFactory
.selectOne()
.from(capsuleSkin)
.join(capsule).on(capsule.capsuleSkin.id.eq(capsuleSkin.id))
.join(capsule).on(capsule.capsuleSkin.eq(capsuleSkin), capsuleSkin.deletedAt.isNull())
.where(capsuleSkin.id.eq(capsuleSkinId).and(capsuleSkin.member.id.eq(memberId))
.and(capsule.deletedAt.isNull()))
.fetchOne();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ public CapsuleSkinDeleteResultDto deleteCapsuleSkin(
final Long memberId,
final Long capsuleSkinId
) {
boolean existRelatedCapsule = capsuleSkinRepository.existRelatedCapsule(memberId, capsuleSkinId);
boolean existRelatedCapsule = capsuleSkinRepository.existRelatedCapsule(memberId,
capsuleSkinId);
if (existRelatedCapsule) {
return CapsuleSkinDeleteResultDto.fail();
}

CapsuleSkin capsuleSkin = capsuleSkinRepository.findCapsuleSkinByMemberIdAndId(memberId, capsuleSkinId)
CapsuleSkin capsuleSkin = capsuleSkinRepository.findCapsuleSkinByMemberIdAndId(memberId,
capsuleSkinId)
.orElseThrow(CapsuleSkinNotFoundException::new);
capsuleSkinRepository.delete(capsuleSkin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Slice<FriendSummaryDto> findFriendReceivingInvitesSlice(
)
)
.from(friendInvite)
.join(friendInvite.owner, member)
.join(member).on(friendInvite.owner.eq(member), member.deletedAt.isNull())
.where(friendInvite.friend.id.eq(memberId).and(friendInvite.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();
Expand All @@ -101,7 +101,7 @@ public Slice<FriendSummaryDto> findFriendSendingInvitesSlice(
)
)
.from(friendInvite)
.join(friendInvite.owner, member)
.join(member).on(friendInvite.owner.eq(member), member.deletedAt.isNull())
.where(friendInvite.owner.id.eq(memberId).and(friendInvite.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public Slice<FriendSummaryDto> findFriendsSlice(
)
)
.from(memberFriend)
.innerJoin(member).on(memberFriend.owner.id.eq(member.id))
.innerJoin(member).on(memberFriend.friend.id.eq(member.id))
.join(member).on(memberFriend.owner.eq(member), member.deletedAt.isNull())
.join(member).on(memberFriend.friend.eq(member), member.deletedAt.isNull())
.where(memberFriend.owner.id.eq(memberId).and(memberFriend.createdAt.lt(createdAt)))
.limit(size + 1)
.fetch();
Expand Down Expand Up @@ -118,13 +118,16 @@ public List<SearchFriendSummaryDto> findFriendsByPhone(
)
.from(member)
.leftJoin(memberFriend)
.on(memberFriend.friend.id.eq(member.id).and(memberFriend.owner.id.eq(memberId)))
.on(memberFriend.friend.id.eq(member.id).and(memberFriend.owner.id.eq(memberId)),
memberFriend.deletedAt.isNull())
.leftJoin(friendInviteToFriend)
.on(friendInviteToFriend.friend.id.eq(member.id)
.and(friendInviteToFriend.owner.id.eq(memberId)))
.and(friendInviteToFriend.owner.id.eq(memberId)),
friendInviteToFriend.deletedAt.isNull())
.leftJoin(friendInviteToMe)
.on(friendInviteToMe.friend.id.eq(memberId)
.and(friendInviteToMe.owner.id.eq(member.id)))
.and(friendInviteToMe.owner.id.eq(member.id)),
friendInviteToMe.deletedAt.isNull())
.where(member.phoneHash.in(hashes).and(member.phoneSearchAvailable.eq(Boolean.TRUE)))
.fetch();
}
Expand Down Expand Up @@ -163,13 +166,16 @@ public Optional<SearchFriendSummaryDtoByTag> findFriendsByTag(
)
.from(member)
.leftJoin(memberFriend)
.on(memberFriend.friend.id.eq(member.id).and(memberFriend.owner.id.eq(memberId)))
.on(memberFriend.friend.id.eq(member.id).and(memberFriend.owner.id.eq(memberId)),
memberFriend.deletedAt.isNull())
.leftJoin(friendInviteToFriend)
.on(friendInviteToFriend.friend.id.eq(member.id)
.and(friendInviteToFriend.owner.id.eq(memberId)))
.and(friendInviteToFriend.owner.id.eq(memberId)),
friendInviteToFriend.deletedAt.isNull())
.leftJoin(friendInviteToMe)
.on(friendInviteToMe.owner.id.eq(member.id)
.and(friendInviteToMe.friend.id.eq(memberId)))
.and(friendInviteToMe.friend.id.eq(memberId)),
friendInviteToMe.deletedAt.isNull())
.where(tagFullTextSearchTemplate.gt(MATCH_THRESHOLD)
.and(member.tagSearchAvailable.eq(Boolean.TRUE)))
.orderBy(tagFullyMatchFirstOrder, tagFullTextSearchTemplate.desc())
Expand Down
Loading
Loading