Skip to content

Commit

Permalink
feat: 로그인한 유저가 북마크한 모임 조회 (#204)
Browse files Browse the repository at this point in the history
* feat: 로그인한 유저가 북마크한 모임 조회

* test: 테스트 코드에 로그인 로직 추가
  • Loading branch information
ddingmin authored Feb 12, 2024
1 parent e5a4953 commit 9c6f2c9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public PageDto<MeetingsResponse> getMeetingsByCondition(
@RequestParam(value = "topic", required = false) Topic topic,
@RequestParam(value = "meetingAreaStreet", required = false) String meetingAreaStreet,
@RequestParam(value = "participantUserId", required = false) Long participantUserId,
@RequestParam(value = "isBookmarked", required = false) Boolean isBookmarked,
@RequestParam(value = "searchWord", required = false) String searchWord) {

Long userId = securityService.getCurrentUserId();
return meetingService.getMeetingsBySpecification(pageable, topic, meetingAreaStreet, participantUserId,
searchWord, isOpen);
searchWord, isBookmarked, isOpen, userId);
}

@PutMapping("/{meetingId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public static Specification<Meeting> withParticipantUserId(Long participantUserI
participantUserId);
}

public static Specification<Meeting> withBookmarkedUserId(Long userId) {
return (root, query, criteriaBuilder) -> criteriaBuilder.equal(root.join("bookmarkedUserIds"), userId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ public void deleteMeeting(Long meetingId, Long userId) {
}

@Transactional(readOnly = true)
public PageDto<MeetingsResponse> getMeetingsBySpecification(Pageable pageable, Topic topic,
String meetingAreaStreet,
Long participantUserId, String searchWord, boolean isOpen) {
public PageDto<MeetingsResponse> getMeetingsBySpecification(Pageable pageable, Topic topic, String meetingAreaStreet,
Long participantUserId, String searchWord, Boolean isBookmarked, boolean isOpen, Long userId) {

Specification<Meeting> spec = MeetingSpecification.withIsOpen(isOpen);

Expand All @@ -110,6 +109,8 @@ public PageDto<MeetingsResponse> getMeetingsBySpecification(Pageable pageable, T
spec = MeetingSpecification.withSearchWordInTitle(searchWord)
.or(MeetingSpecification.withSearchWordInIntroduction(searchWord))
.and(MeetingSpecification.withIsOpen(isOpen));
} else if (Boolean.TRUE.equals(isBookmarked)) {
spec = spec.and(MeetingSpecification.withBookmarkedUserId(userId));
}

var meetings = meetingRepository.findAll(spec, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class Find_meeting_list_api {
@DisplayName("존재하는 topic이 주어지면 페이지 네이션을 적용해 미팅 목록을 최신순으로 응답한다.")
void Return_meeting_list_if_topic_and_page_nation_received() {
// given
var user = repository.saveAndGetUser();
securityContextSetting.set(user.getId());
var size = 2;
var openMeetingsByTopic = repository.saveAndGetOpenMeetingsByTopic(size, Topic.스터디);
var closeTopicMeetingsByTopic = repository.saveAndGetOpenMeetingsByTopic(size, Topic.고민_나누기);
Expand Down Expand Up @@ -169,6 +171,8 @@ void Return_meeting_list_if_topic_and_page_nation_received() {
@DisplayName("제목이나 설명에 존재하는 검색어가 주어지면 페이지 네이션을 적용해 미팅 목록을 최신순으로 응답한다.")
void Return_meeting_list_if_search_word_and_page_nation_received() {
// given
var user = repository.saveAndGetUser();
securityContextSetting.set(user.getId());
var size = 2;
var openMeetingsByTitle = repository.saveAndGetOpenMeetingsByTitle(size, "개발자 스터디");
var closeMeetingsByTitle = repository.saveAndGetCloseMeetingsByTitle(size, "개발자 스터디");
Expand Down Expand Up @@ -201,6 +205,8 @@ void Return_meeting_list_if_search_word_and_page_nation_received() {
@DisplayName("참여자 id가 주어지면 페이지 네이션을 적용해 미팅 목록을 최신순으로 응답한다.")
void Return_meeting_list_if_participant_user_id_and_page_nation_received() {
// given
var user = repository.saveAndGetUser();
securityContextSetting.set(user.getId());
var size = 2;
var openMeetingsByParticipantUserId = repository.saveAndGetOpenMeetingsByParticipantUserId(size, 2L);
var closeMeetingsByParticipantUserId = repository.saveAndGetCloseMeetingsByParticipantUserId(size, 2L);
Expand Down Expand Up @@ -229,6 +235,8 @@ void Return_meeting_list_if_participant_user_id_and_page_nation_received() {
@DisplayName("요청한 size와 page보다 더 많은 데이터가 존재하면, hasNext를 true로 응답한다.")
void Return_has_next_true_if_more_data_exists_than_requested_size_and_page() {
// given
var user = repository.saveAndGetUser();
securityContextSetting.set(user.getId());
var size = 10;
var openMeetingsByTopic = repository.saveAndGetOpenMeetingsByTopic(size, Topic.스터디);

Expand Down

0 comments on commit 9c6f2c9

Please sign in to comment.