Skip to content

Commit

Permalink
refactor: 메서드 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
ashsty committed Nov 15, 2024
1 parent fb014df commit f4eec6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/src/main/java/corea/alarm/service/AlarmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,19 @@ public AlarmResponses getAlarm(long userId) {
AlarmsByActionType userAlarms = userToUserAlarmReader.findAllByReceiver(member);
AlarmsByActionType serverAlarms = serverToUserAlarmReader.findAllByReceiver(member);

List<Alarm> allAlarms = Stream.concat(
userAlarms.getList().stream(),
serverAlarms.getList().stream()
).toList();
List<Alarm> allAlarms = mergeAlarms(userAlarms, serverAlarms);

Map<Long, Member> actors = memberReader.findMembersMappedById(userAlarms.getActorIds());
Map<Long, Room> userAlarmRooms = roomReader.findRoomsMappedById(userAlarms.getRoomIds());
Map<Long, Room> serverAlarmRooms = roomReader.findRoomsMappedById(serverAlarms.getRoomIds());

return AlarmResponses.of(allAlarms, actors, userAlarmRooms, serverAlarmRooms);
}

private List<Alarm> mergeAlarms(AlarmsByActionType userAlarms, AlarmsByActionType serverAlarms) {
return Stream.concat(
userAlarms.getList().stream(),
serverAlarms.getList().stream()
).toList();
}
}

0 comments on commit f4eec6b

Please sign in to comment.