Skip to content

Commit 1e0cc44

Browse files
authored
Merge pull request #36 from AI-Tutor-2024/develop
Develop
2 parents 5d0c396 + f20d975 commit 1e0cc44

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/main/java/com/example/ai_tutor/domain/note/presentation/NoteController.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import com.example.ai_tutor.domain.note.application.ProfessorNoteService;
44
import com.example.ai_tutor.domain.note.dto.request.NoteCreateReq;
5+
import com.example.ai_tutor.domain.note.dto.response.NoteAccessRes;
56
import com.example.ai_tutor.domain.note.dto.response.NoteCodeRes;
67
import com.example.ai_tutor.domain.note.dto.response.NoteListRes;
78
import com.example.ai_tutor.domain.practice.dto.request.SavePracticeListReq;
89
import com.example.ai_tutor.domain.summary.application.SummaryService;
10+
import com.example.ai_tutor.domain.summary.dto.response.SummaryRes;
911
import com.example.ai_tutor.global.config.security.token.UserPrincipal;
1012
import com.example.ai_tutor.global.payload.ErrorResponse;
1113
import com.example.ai_tutor.global.payload.Message;
@@ -42,7 +44,7 @@ public class NoteController {
4244
description = "새 비어있는 강의 노트를 생성하는 API입니다. 특정 folder ID에 title(강의 제목) 값만 요청하면 됩니다. 이때 폴더 ID 는 로그인한 회원이 생성한 폴더만 노트가 생성 가능합니다. (타인 계정으로 불가능)"
4345
)
4446
@ApiResponses(value = {
45-
@ApiResponse(responseCode = "200", description = "강의 노트 생성 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Message.class) ) } ),
47+
@ApiResponse(responseCode = "200", description = "강의 노트 생성 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = NoteAccessRes.class) ) } ),
4648
@ApiResponse(responseCode = "400", description = "강의 노트 생성 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
4749
})
4850
@PostMapping()
@@ -115,7 +117,7 @@ public ResponseEntity<?> convertSpeechToText(
115117
@Parameter(description = "노트 ID", required = true) @PathVariable Long noteId,
116118
@Parameter(description = "STT 변환을 위한 강의 영상 파일", required = true,
117119
schema = @Schema(type = "string", format = "binary"))
118-
@RequestPart MultipartFile file
120+
@RequestPart("file") MultipartFile file
119121
) {
120122
try {
121123
boolean success = professorNoteService.convertSpeechToText(noteId, file);
@@ -134,29 +136,26 @@ public ResponseEntity<?> convertSpeechToText(
134136
// ===============================
135137
// 📑 노트 요약 생성 & 조회
136138
// ===============================
137-
138139
@Operation(summary = "노트 요약 생성", security = { @SecurityRequirement(name = "BearerAuth") }, description = "저장된 STT 데이터를 기반으로 노트 요약을 생성합니다.")
139140
@ApiResponses({
140141
@ApiResponse(responseCode = "200", description = "노트 요약 생성 성공",
141-
content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))),
142+
content = @Content(mediaType = "application/json", schema = @Schema(implementation = SummaryRes.class))),
142143
@ApiResponse(responseCode = "400", description = "노트 요약 생성 실패",
143144
content = @Content(mediaType = "application/json"))
144145
})
145146
@PreAuthorize("isAuthenticated()")
146147
@PostMapping("/{noteId}/summaries")
147-
public Mono<ResponseEntity<String>> createSummary(
148+
public Mono<ResponseEntity<SummaryRes>> createSummary(
148149
@Parameter(description = "note id를 입력해주세요", required = true) @PathVariable Long noteId,
149150
@Parameter(description = "folder의 id를 입력해주세요", required = true) @PathVariable Long folderId,
150151
@RequestParam(required = false) String keywords,
151152
@RequestParam(required = false) String requirement) {
152153

153154
return summaryService.processSummaryFromSavedStt(noteId, keywords, requirement)
154155
.map(ResponseEntity::ok)
155-
.onErrorResume(error -> {
156-
return Mono.just(ResponseEntity
157-
.badRequest()
158-
.body(error.getMessage()));
159-
});
156+
.onErrorResume(error -> Mono.just(ResponseEntity
157+
.badRequest()
158+
.build()));
160159
}
161160

162161

src/main/java/com/example/ai_tutor/domain/summary/application/SummaryService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public ResponseEntity<?> getSummary(Long noteId) {
251251
// 요약 조회 로직 구현
252252
Summary summary = findSummaryByNote(note);
253253
SummaryRes sttRes = SummaryRes.builder()
254+
.noteId(summary.getNote().getNoteId())
254255
.summary(summary.getContent())
255256
.build();
256257

@@ -284,9 +285,8 @@ private Summary findSummaryByNote(Note note){
284285
* 저장된 STT 데이터를 사용하여 요약을 생성하고 결과를 반환합니다.
285286
*/
286287
@Transactional
287-
public Mono<String> processSummaryFromSavedStt(Long noteId, String keywords, String requirement) {
288+
public Mono<SummaryRes> processSummaryFromSavedStt(Long noteId, String keywords, String requirement) {
288289
return Mono.fromCallable(() -> {
289-
// 1. note 조회 및 fullText 추출 (블로킹)
290290
Note note = noteRepository.findById(noteId)
291291
.orElseThrow(() -> new RuntimeException("해당 노트를 찾을 수 없습니다."));
292292

@@ -308,19 +308,19 @@ public Mono<String> processSummaryFromSavedStt(Long noteId, String keywords, Str
308308
.flatMap(partialSummaries -> summarizeFinal(partialSummaries, keywords, requirement))
309309
.flatMap(finalSummary -> Mono.fromCallable(() -> {
310310

311-
// 기존 summary가 있는지 확인하고
312311
summaryRepository.findByNote(note)
313312
.ifPresent(existing -> {
314-
// 있으면 삭제
315313
summaryRepository.delete(existing);
316314
log.info("기존 summary 삭제 완료 (noteId: {})", note.getNoteId());
317315
});
318316

319-
// 새로운 summary 생성 및 저장
320317
Summary summary = Summary.create(finalSummary, note);
321318
summaryRepository.save(summary);
322319

323-
return finalSummary;
320+
return SummaryRes.builder()
321+
.noteId(note.getNoteId())
322+
.summary(finalSummary)
323+
.build();
324324

325325
}).subscribeOn(Schedulers.boundedElastic()));
326326
})

src/main/java/com/example/ai_tutor/domain/summary/dto/response/SummaryRes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
@AllArgsConstructor
1212
@NoArgsConstructor
1313
public class SummaryRes {
14+
@Schema(description = "노트 번호")
15+
private Long noteId;
1416
@Schema(description = "요약된 텍스트")
1517
private String summary;
1618
}

0 commit comments

Comments
 (0)