Skip to content

Commit

Permalink
refactor: 토론 요약 DebateRoomService로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjy committed May 7, 2024
1 parent 04311fb commit e5e024e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public List<DebateMessageResponse> getDebateMessages(@PathVariable final Long ro
@GetMapping("/summary/{roomId}")
@Override
public DebateSummaryResponse getSummarizedDebate(@PathVariable final Long roomId) {
return debateMessageService.summaryDebateMessages(roomId);
return debateRoomService.summaryDebateMessages(roomId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class DebateMessageService {
private final DebateRoomRepository debateRoomRepository;
private final DebateMessageRepository debateMessageRepository;
private final DebateMessageMapper debateMessageMapper;
private final ClovaSummary clovaSummary;

@Transactional
public void saveHumanDebateMessage(final Long roomId, DebateMessageRequest request) {
Expand All @@ -48,15 +47,4 @@ public List<DebateMessageResponse> getDebateMessages(Long roomId) {
.stream().map(debateMessageMapper::toResponse)
.collect(Collectors.toList());
}

public DebateSummaryResponse summaryDebateMessages(final Long roomId) {
StringBuilder sb = new StringBuilder();
getDebateMessages(roomId).forEach(message -> sb.append(message.getMessage()));
return DebateSummaryResponse.builder()
.roomId(roomId)
.summary(clovaSummary.summaryDebate(sb.toString()))
.build();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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.mapper.DebateRoomMapper;
import com.rollthedice.backend.domain.debate.repository.DebateRoomRepository;
import com.rollthedice.backend.domain.member.entity.Member;
Expand All @@ -21,6 +22,7 @@ public class DebateRoomService {
private final DebateRoomMapper debateRoomMapper;
private final DebateRoomRepository debateRoomRepository;
private final DebateMessageService debateMessageService;
private final ClovaSummary clovaSummary;


@Transactional
Expand All @@ -42,4 +44,14 @@ public void deleteDebateRoom(Long roomId) {
debateMessageService.deleteAllDebateMessages(roomId);
debateRoomRepository.deleteById(roomId);
}

@Transactional
public DebateSummaryResponse summaryDebateMessages(final Long roomId) {
StringBuilder sb = new StringBuilder();
debateMessageService.getDebateMessages(roomId).forEach(message -> sb.append(message.getMessage()));
return DebateSummaryResponse.builder()
.roomId(roomId)
.summary(clovaSummary.summaryDebate(sb.toString()))
.build();
}
}

0 comments on commit e5e024e

Please sign in to comment.