Skip to content

Commit

Permalink
[Refactoring] 최대 최소 인원 함수 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
AreSain committed Aug 27, 2024
1 parent 80c7daf commit c7f3be2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ public void slackConfirmAgendaTeam(Agenda agenda, AgendaTeam newTeam) {
String message = snsMessageUtil.confirmTeamMessage(agenda, newTeam);
agendaTeamProfiles.stream().map(atp -> atp.getProfile().getIntraId())
.forEach(intraId -> messageSender.send(intraId, message));
String toHostMessage = snsMessageUtil.agendaHostMessage(agenda);
if (toHostMessage != null) {
if (agenda.getMinTeam() == agenda.getCurrentTeam()) {
String toHostMessage = snsMessageUtil.agendaHostMinTeamSatisfiedMessage(agenda);
messageSender.send(agenda.getHostIntraId(), toHostMessage);
}
if (agenda.getMaxTeam() == agenda.getCurrentTeam()) {
String toHostMessage = snsMessageUtil.agendaHostMaxTeamSatisfiedMessage(agenda);
messageSender.send(agenda.getHostIntraId(), toHostMessage);
}
}
Expand All @@ -79,8 +83,7 @@ public void slackAttendTeamMate(Agenda agenda, AgendaTeam agendaTeam, String use
List<AgendaTeamProfile> agendaTeamProfiles = agendaTeamProfileRepository.findByAgendaTeamAndIsExistTrue(
agendaTeam);
String message = snsMessageUtil.attendTeamMateMessage(agenda, agendaTeam, userIntraId);
agendaTeamProfiles.stream()
.map(atp -> atp.getProfile().getIntraId())
agendaTeamProfiles.stream().map(atp -> atp.getProfile().getIntraId())
.filter(intraId -> !intraId.equals(userIntraId))
.forEach(intraId -> messageSender.send(intraId, message));
}
Expand Down
28 changes: 13 additions & 15 deletions gg-agenda-api/src/main/java/gg/agenda/api/utils/SnsMessageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,18 @@ public String leaveTeamMateMessage(Agenda agenda, AgendaTeam agendaTeam, String
+ "\n" + agenda.getTitle() + "의" + agendaTeam.getName() + "팀에서" + intraId + "님이 탈퇴했습니다.";
}

public String agendaHostMessage(Agenda agenda) {
if (agenda.getMinTeam() == agenda.getCurrentTeam()) {
return SUBJECT
+ "\n" + agenda.getTitle() + "행사가 최소 팀 개수를 충족했습니다."
+ "\n" + "행사를 확정할 수 있습니다."
+ "\n" + "확정시엔 다른 팀들이 참가 할 수 없으니, 주의하세요!"
+ "\n" + "$$" + URL + "agenda_key=" + agenda.getAgendaKey() + "$$";
}
if (agenda.getMaxTeam() == agenda.getCurrentTeam()) {
return SUBJECT
+ "\n" + agenda.getTitle() + "행사가 최대 팀 개수를 충족했습니다."
+ "\n" + "행사를 확정하고 진행 시간과 장소를 공지사항으로 전달해주세요."
+ "\n" + "$$" + URL + "agenda_key=" + agenda.getAgendaKey() + "$$";
}
return null;
public String agendaHostMinTeamSatisfiedMessage(Agenda agenda) {
return SUBJECT
+ "\n" + agenda.getTitle() + "행사가 최소 팀 개수를 충족했습니다."
+ "\n" + "행사를 확정할 수 있습니다."
+ "\n" + "확정시엔 다른 팀들이 참가 할 수 없으니, 주의하세요!"
+ "\n" + "$$" + URL + "agenda_key=" + agenda.getAgendaKey() + "$$";
}

public String agendaHostMaxTeamSatisfiedMessage(Agenda agenda) {
return SUBJECT
+ "\n" + agenda.getTitle() + "행사가 최대 팀 개수를 충족했습니다."
+ "\n" + "행사를 확정하고 진행 시간과 장소를 공지사항으로 전달해주세요."
+ "\n" + "$$" + URL + "agenda_key=" + agenda.getAgendaKey() + "$$";
}
}

0 comments on commit c7f3be2

Please sign in to comment.