Skip to content

Commit

Permalink
feat: summary 저장 관련 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjy committed May 7, 2024
1 parent e5e024e commit 6dc5beb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public List<DebateMessageResponse> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}

0 comments on commit 6dc5beb

Please sign in to comment.