diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java index 4a1f3928..9fe8eec2 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.RequestBody; @@ -22,7 +23,7 @@ public interface DebateApi { summary = "토론방 생성", description = "주제가 선택된 토론방을 생성합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_room"} + tags = {"토론방"} ) @ApiResponse( responseCode = "201", @@ -34,11 +35,11 @@ public interface DebateApi { summary = "토론방 전체 조회", description = "회원의 토론방을 페이지로 나누어 조회합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_room"} + tags = {"토론방"} ) @ApiResponse( responseCode = "200", - description = "OK" + description = "요청에 성공하였습니다." ) List getDebateRooms(Pageable pageable); @@ -46,11 +47,11 @@ public interface DebateApi { summary = "토론방 삭제", description = "토론방을 삭제합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_room"} + tags = {"토론방"} ) @ApiResponse( responseCode = "204", - description = "No Content" + description = "토론방 삭제에 성공하였으며, 응답값은 없습니다." ) void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId @@ -60,7 +61,7 @@ void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 summary = "[인간] 토론 메세지 저장", description = "사용자가 보낸 토론 메세지를 저장합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_message"} + tags = {"토론 메세지"} ) @ApiResponse( responseCode = "201", @@ -77,7 +78,7 @@ void saveHumanDebateMessage( summary = "[AI] 토론 메세지 저장", description = "ChatGPT OPENAI가 보낸 토론 메세지를 저장합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_message"} + tags = {"토론 메세지"} ) @ApiResponse( responseCode = "201", @@ -90,15 +91,36 @@ void saveAIDebateMessage( @RequestBody DebateMessageRequest request ); + @Operation( + summary = "토론 종료", + description = "토론을 종료합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"토론방"} + ) + @ApiResponses(value = { + @ApiResponse( + responseCode = "204", + description = "요청에 성공하였으며 응답값은 없습니다." + ), + @ApiResponse( + responseCode = "404", + description = "토론방을 찾지 못했습니다." + ) + }) + void finishDebate( + @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId + ); + @Operation( summary = "토론 메세지 조회", description = "토론방의 토론 메세지 이력을 조회합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_message"} + tags = {"토론 메세지"} ) @ApiResponse( responseCode = "200", - description = "OK" + description = "요청에 성공하였습니다." ) List getDebateMessages( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) @@ -109,19 +131,42 @@ List getDebateMessages( summary = "토론 요약", description = "토론방의 토론 메세지들을 요약합니다.", security = {@SecurityRequirement(name = "access_token")}, - tags = {"debate_message"} + tags = {"토론방"} ) - @ApiResponse( - responseCode = "200", - description = "OK" + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "토론 요약이 성공하였습니다." + ), + @ApiResponse( + responseCode = "404", + description = "토론방을 찾지 못했습니다." + ) + }) + DebateSummaryResponse summarizeDebate( + @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId + ); + + @Operation( + summary = "토론 요약 조회", + description = "토론 요약 내용을 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"토론방"} ) + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "요청에 성공하였습니다." + ), + @ApiResponse( + responseCode = "404", + description = "토론방을 찾지 못했습니다." + ) + }) DebateSummaryResponse getSummarizedDebate( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); - - - - } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java index f6c0a530..4e802ef3 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java @@ -57,17 +57,30 @@ public void saveAIDebateMessage(@PathVariable final Long roomId, @RequestBody fi debateMessageService.saveAIDebateMessage(roomId, request); } - @ResponseStatus(HttpStatus.OK) + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/{roomId}") + public void finishDebate(@PathVariable final Long roomId) { + debateRoomService.closeDebate(roomId); + } + + @ResponseStatus(HttpStatus.CREATED) @GetMapping("/{roomId}") @Override public List getDebateMessages(@PathVariable final Long roomId) { return debateMessageService.getDebateMessages(roomId); } + @ResponseStatus(HttpStatus.OK) + @PostMapping("/summary/{roomId}") + @Override + public DebateSummaryResponse summarizeDebate(@PathVariable final Long roomId) { + return debateRoomService.summaryDebate(roomId); + } + @ResponseStatus(HttpStatus.OK) @GetMapping("/summary/{roomId}") @Override public DebateSummaryResponse getSummarizedDebate(@PathVariable final Long roomId) { - return debateRoomService.summaryDebate(roomId); + return debateRoomService.getSummarizedDebate(roomId); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/dto/response/DebateRoomResponse.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/dto/response/DebateRoomResponse.java index 64eae208..27d3d766 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/dto/response/DebateRoomResponse.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/dto/response/DebateRoomResponse.java @@ -12,4 +12,5 @@ public class DebateRoomResponse { private Long id; private String topic; + private Boolean isClosed; } 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 fb94b037..595359ed 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.entity.DebateRoom; import com.rollthedice.backend.domain.debate.exception.DebateRoomNotFoundException; import com.rollthedice.backend.domain.debate.mapper.DebateRoomMapper; import com.rollthedice.backend.domain.debate.repository.DebateRoomRepository; @@ -48,15 +49,28 @@ public void deleteDebateRoom(Long roomId) { @Transactional public DebateSummaryResponse summaryDebate(final Long roomId) { + DebateRoom room = debateRoomRepository.findById(roomId).orElseThrow(DebateRoomNotFoundException::new); StringBuilder sb = debateMessageService.getAllMessages(roomId); String summary = clovaSummary.summaryDebate(sb.toString()); - debateRoomRepository.findById(roomId).orElseThrow(DebateRoomNotFoundException::new) - .updateSummary(summary); + room.updateSummary(summary); return DebateSummaryResponse.builder() .roomId(roomId) - .summary(summary) + .summary(room.getSummary()) .build(); } + public DebateSummaryResponse getSummarizedDebate(final Long roomId) { + DebateRoom room = debateRoomRepository.findById(roomId).orElseThrow(DebateRoomNotFoundException::new); + return DebateSummaryResponse.builder() + .roomId(roomId) + .summary(room.getSummary()) + .build(); + } + + @Transactional + public void closeDebate(final Long roomId) { + DebateRoom room = debateRoomRepository.findById(roomId).orElseThrow(DebateRoomNotFoundException::new); + room.closeDebate(); + } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java index 6b34086a..ea9e1072 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java @@ -17,11 +17,7 @@ @RequiredArgsConstructor @Service public class MemberService { - private final AuthService authService; - private final RefreshTokenService refreshTokenService; - private final JwtService jwtService; - private final HttpServletRequest request; - private final HttpServletResponse response; + private final AuthService authService;; private final MemberRepository memberRepository;