Skip to content

Commit

Permalink
Merge pull request #60 from Kusitms-29th-Meetup-TeamE/feat/58/partici…
Browse files Browse the repository at this point in the history
…pant

Fix: 채팅방 상태를 활동 참여자 수 데이터에 반영
  • Loading branch information
nohy6630 authored May 19, 2024
2 parents 8616ddc + 52df827 commit 1f3c49c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ public static Activity of(String title, String description, String location, Loc
.imageUrl(imageUrl)
.build();
}

public void incrementCurrentParticipants() {
this.currentParticipants++;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ public ReadDirectChatRoomsRes readDirectChatRooms() {

@Transactional
public Long joinGroupChatRoom(Long activityId) {
Activity activity = activityRepository.findById(activityId)
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_ACTIVITY));
Long userId = SecurityContextProvider.getAuthenticatedUserId();
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER));
GroupChatRoom groupChatRoom = groupChatRoomRepository.findByActivityId(activityId)
.orElseGet(() -> {
Activity activity = activityRepository.findById(activityId)
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_ACTIVITY));
return groupChatRoomRepository.save(GroupChatRoom.of(activity));
});
if (userChatRoomRepository.existsByChatRoomIdAndUserId(groupChatRoom.getId(), user.getId()))
throw new CustomException(ExceptionContent.BAD_REQUEST_ALREADY_JOIN_CHATROOM);
userChatRoomRepository.save(UserChatRoom.of(groupChatRoom, user));
activity.incrementCurrentParticipants();
return groupChatRoom.getId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static ExperienceRes of(Experience experience) {
.age(experience.getUser().getAge())
.gender(experience.getUser().getGender().getDescription())
.location(experience.getUser().getLocation())
.message(experience.getDescription())
.message(experience.getDetail())
.build();
}
}

0 comments on commit 1f3c49c

Please sign in to comment.