From 6dc5beb7ec9a891f0cbaf02c96f3ca1d3455e394 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Wed, 8 May 2024 03:11:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20summary=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/debate/service/DebateMessageService.java | 7 +++++++ .../domain/debate/service/DebateRoomService.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateMessageService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateMessageService.java index 8680945f..032ee552 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateMessageService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateMessageService.java @@ -47,4 +47,11 @@ public List getDebateMessages(Long roomId) { .stream().map(debateMessageMapper::toResponse) .collect(Collectors.toList()); } + + public StringBuilder getAllMessages(Long roomId) { + StringBuilder sb = new StringBuilder(); + getDebateMessages(roomId) + .forEach(message -> sb.append(message.getMessage())); + return sb; + } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateRoomService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateRoomService.java index 5b112b20..fb94b037 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateRoomService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/DebateRoomService.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.debate.dto.request.DebateRoomRequest; import com.rollthedice.backend.domain.debate.dto.response.DebateRoomResponse; import com.rollthedice.backend.domain.debate.dto.response.DebateSummaryResponse; +import com.rollthedice.backend.domain.debate.exception.DebateRoomNotFoundException; import com.rollthedice.backend.domain.debate.mapper.DebateRoomMapper; import com.rollthedice.backend.domain.debate.repository.DebateRoomRepository; import com.rollthedice.backend.domain.member.entity.Member; @@ -46,12 +47,16 @@ public void deleteDebateRoom(Long roomId) { } @Transactional - public DebateSummaryResponse summaryDebateMessages(final Long roomId) { - StringBuilder sb = new StringBuilder(); - debateMessageService.getDebateMessages(roomId).forEach(message -> sb.append(message.getMessage())); + public DebateSummaryResponse summaryDebate(final Long roomId) { + StringBuilder sb = debateMessageService.getAllMessages(roomId); + String summary = clovaSummary.summaryDebate(sb.toString()); + debateRoomRepository.findById(roomId).orElseThrow(DebateRoomNotFoundException::new) + .updateSummary(summary); + return DebateSummaryResponse.builder() .roomId(roomId) - .summary(clovaSummary.summaryDebate(sb.toString())) + .summary(summary) .build(); } + }