Skip to content
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 @@ -46,6 +46,7 @@ public static HomeResponse.CompletedVoteRoom toCompletedVoteRoom(TripPlan tripPl
tripPlan.getRoom().getName(),
aiCourseId,
tripPlan.getLocation(),
tripPlan.getTripPlanType(),
tripPlan.getStartDate(),
tripPlan.getEndDate().format(DATE_FORMATTER),
tripPlan.getImageUrl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static class CompletedVoteRoom {
private String roomName;
private Long aiCourseId;
private String location;
private TripPlanType tripPlanType;
private LocalDate startDate;
private String endDate;
private String imageUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void createRoom(CreateRoomRequest request, String userEmail) {
// 방 멤버 추가
List<User> users = userRepository.findAllById(request.getUserIds());

// 방장 추가
if (!users.contains(master)) { // 중복 추가 방지
users.add(master);
}

List<RoomMember> newRoomMembers = users.stream()
.map(user -> RoomMemberConverter.fromRequest(room, user))
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Vote extends BaseEntity {
@JsonIgnore
private VoteRoom voteRoom;


@Enumerated(EnumType.STRING)
@Column(nullable = false)
private VoteType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface VoteRepository extends JpaRepository<Vote,Long> {
@Query("DELETE FROM Vote v WHERE v.voteRoom IN (SELECT vr FROM VoteRoom vr WHERE vr.tripPlan.user = :user)")
void deleteByVoteRoomUser(@Param("user") User user);

Optional<Vote> findByUserAndTripPlan(User user, TripPlan tripPlan);
@Query("SELECT v FROM Vote v WHERE v.tripPlan.id = :tripPlanId AND v.id = (SELECT u.vote.id FROM User u WHERE u.id = :userId)")
Optional<Vote> findByUserIdAndTripPlanId(@Param("userId") Long userId, @Param("tripPlanId") Long tripPlanId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void createVote(VoteRequest.createVoteReq request, String userEmail) {
}

// 기존 투표 여부 확인
Optional<Vote> existingVote = voteRepository.findByUserAndTripPlan(user, tripPlan);
Optional<Vote> existingVote = voteRepository.findByUserIdAndTripPlanId(user.getId(), tripPlan.getId());

if (existingVote.isPresent()) {
Vote currentVote = existingVote.get();
Expand Down