Skip to content

Commit

Permalink
Merge pull request #147 from dodunge/055-MYLOUNGE/BOOKMARK
Browse files Browse the repository at this point in the history
feat:[055-MYLOUNGE/BOOKMARK] 마이 라운지에서 북마크한 그룹만 조회 API 작성
  • Loading branch information
eod940 committed Mar 13, 2024
2 parents d77bfcc + a9e9af1 commit a215060
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ public ResponseEntity<TripGroupStatusListDto> getMyTripGroupList(
return ResponseEntity.ok(tripGroupStatusListDto);
}

@ApiOperation(value = "나의 관심 그룹 리스트 조회 API",
notes = "내가 북마크 한 여행 그룹\n")
@GetMapping("/list/my-bookmark")
public ResponseEntity<TripGroupStatusListDto> getMyBookmarkList(
@RequestHeader("Authorization") String token,
@RequestParam(defaultValue = "1") int page
) {
Pageable pageable = PageRequest.of(page - 1, 8);
Page<TripGroupStatusResponseDto> myTripGroupList = tripGroupListService.getMyBookmarkTripGroupList(tokenService.getMemberId(token), pageable);
TripGroupStatusListDto tripGroupStatusListDto = TripGroupStatusListDto.from(myTripGroupList);
return ResponseEntity.ok(tripGroupStatusListDto);
}

private Sort sortDirection(String sort) {
if ("deadline".equals(sort)) {
return Sort.by("dueDate").ascending();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public interface TripGroupRepositoryCustom {
void updateTripGroupStatusToClose();

List<TripGroup> findChatRoomByMemberId(Long memberId);

Page<TripGroup> findBookmarkTripGroups(Long memberId, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.valuewith.tweaver.bookmark.entity.QBookmark;
import com.valuewith.tweaver.constants.ApprovedStatus;
import com.valuewith.tweaver.constants.GroupStatus;
import com.valuewith.tweaver.group.entity.QTripGroup;
Expand All @@ -27,6 +28,7 @@ public class TripGroupRepositoryCustomImpl implements TripGroupRepositoryCustom
private final JPAQueryFactory queryFactory;
private final QTripGroup qTripGroup = QTripGroup.tripGroup;
private final QGroupMember qGroupMember = QGroupMember.groupMember;
private final QBookmark qBookmark = QBookmark.bookmark;

@Override
public List<TripGroup> findFilteredTripGroups(
Expand Down Expand Up @@ -140,6 +142,26 @@ public List<TripGroup> findChatRoomByMemberId(Long memberId) {
.fetch();
}

@Override
public Page<TripGroup> findBookmarkTripGroups(Long memberId, Pageable pageable) {
List<TripGroup> tripGroups = queryFactory
.select(qTripGroup)
.from(qTripGroup)
.leftJoin(qBookmark).on(qBookmark.tripGroup.eq(qTripGroup))
.where(qBookmark.member.memberId.eq(memberId))
.orderBy(qTripGroup.createdDateTime.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();

long total = queryFactory
.selectFrom(qTripGroup)
.where(qTripGroup.member.memberId.eq(memberId))
.fetchCount();

return new PageImpl<>(tripGroups, pageable, total);
}


// 스프링의 Sort 객체를 QueryDSL OrderSpecifier로 변환
private List<OrderSpecifier> sortOrder(Sort sort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ public Page<TripGroupStatusResponseDto> getMyTripGroupList(
return tripGroups.map(TripGroupStatusResponseDto::from);

}

public Page<TripGroupStatusResponseDto> getMyBookmarkTripGroupList(Long memberId, Pageable pageable) {
Page<TripGroup> tripGroups = tripGroupRepository.findBookmarkTripGroups(memberId, pageable);
return tripGroups.map(TripGroupStatusResponseDto::from);
}
}

0 comments on commit a215060

Please sign in to comment.