Skip to content

Commit

Permalink
Merge branch 'develop_back_core' into feat/friend_tag-B-#452
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 authored May 29, 2024
2 parents 7a767b0 + 8b3b09f commit 1824c1a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ public record GroupDetailDto(
List<GroupMemberDto> members
) {

public static GroupDetailDto as(
String groupName,
String groupDescription,
String groupProfileUrl,
ZonedDateTime createdAt,
List<GroupMemberDto> members
) {
return new GroupDetailDto(groupName, groupDescription, groupProfileUrl, createdAt, members);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -59,12 +60,11 @@ public Slice<GroupSummaryDto> findGroupsSlice(

public Optional<GroupDetailDto> findGroupDetailByGroupIdAndMemberId(final Long groupId,
final Long memberId) {
return Optional.ofNullable(
GroupDetailDto groupDetailDtoIncludeMe =
jpaQueryFactory
.selectFrom(group)
.join(memberGroup).on(memberGroup.group.id.eq(groupId))
.join(member).on(member.id.eq(memberGroup.member.id))
.where(member.id.ne(memberId))
.transform(
groupBy(group.id).as(
Projections.constructor(
Expand All @@ -86,7 +86,23 @@ public Optional<GroupDetailDto> findGroupDetailByGroupIdAndMemberId(final Long g
)
)
)
.get(groupId)
.get(groupId);

if (Objects.isNull(groupDetailDtoIncludeMe)) {
return Optional.empty();
}

List<GroupMemberDto> groupMemberDtosExcludeMe = groupDetailDtoIncludeMe.members().stream()
.filter(memberDto -> !memberDto.memberId().equals(memberId))
.toList();

return Optional.of(
GroupDetailDto.as(
groupDetailDtoIncludeMe.groupName(),
groupDetailDtoIncludeMe.groupDescription(),
groupDetailDtoIncludeMe.groupProfileUrl(),
groupDetailDtoIncludeMe.createdAt(),
groupMemberDtosExcludeMe)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public Slice<GroupSummaryDto> findGroupsSlice(

public GroupDetailTotalDto findGroupDetailByGroupId(final Long memberId, final Long groupId) {
final GroupDetailDto groupDetailDto = groupRepository.findGroupDetailByGroupIdAndMemberId(
groupId,
memberId).orElseThrow(GroupNotFoundException::new);
groupId, memberId).orElseThrow(GroupNotFoundException::new);

final Long groupCapsuleCount = groupCapsuleQueryRepository.findGroupCapsuleCount(groupId);
final Boolean canGroupEdit = groupRepository.findGroupEditPermission(groupId, memberId);
Expand Down

0 comments on commit 1824c1a

Please sign in to comment.