Skip to content

Commit

Permalink
Merge pull request #277 from Hous-Release/develop
Browse files Browse the repository at this point in the history
release 1.0.1
  • Loading branch information
orijoon98 authored Dec 18, 2022
2 parents 90a8481 + 5e24ea2 commit 6868b01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/hous/server/domain/room/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public static Room newInstance(Onboarding owner, String name, String code) {
.build();
}

public void updateOwner(Onboarding onboarding) {
this.owner = onboarding;
}

public void updateRoomName(String name) {
this.name = name;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/hous/server/service/room/RoomServiceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -105,5 +106,10 @@ public static void deleteParticipateUser(ParticipateRepository participateReposi
room.deleteParticipate(participate);
me.deleteParticipate(participate);
participateRepository.delete(participate);
if (me.getId().equals(room.getOwner().getId())) {
Optional<Participate> nextOwnerParticipate = room.getParticipates().stream()
.min(Comparator.comparing(Participate::getCreatedAt));
nextOwnerParticipate.ifPresent(nextOwner -> room.updateOwner(nextOwner.getOnboarding()));
}
}
}

0 comments on commit 6868b01

Please sign in to comment.