Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@Slf4j
@RestController
Expand All @@ -38,63 +37,16 @@ public class AnalysisReportController {
// 안전지수, 지피티 분석 설명 반환하는 api -> 단, s3 url 가지고 파일 객체
// 생성해야함!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@Operation(summary = "등기부등본 분석 결과 API", description = "분석리포트 페이지에 결과 반환")
@PostMapping(
value = "/analysis-result",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter getAnalysisReport(
@PostMapping(value = "/analysis-result", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<BaseResponse<AnalysisReportResponse>> getAnalysisReport(
@Parameter(description = "업로드할 파일") @RequestParam("file") MultipartFile file,
@Parameter(description = "전월세 여부") @RequestParam("isMonthlyRent") Integer isMonthlyRent,
@Parameter(description = "전월세 보증금") @RequestParam("deposit") Long deposit,
@Parameter(description = "월세") @RequestParam("monthlyRent") Integer monthlyRent,
@Parameter(description = "상세 주소") @RequestParam("detailAddress") String detailAddress,
@Parameter(description = "예시 파일 여부") @RequestParam("isExample") Integer isExample) {

SseEmitter emitter = new SseEmitter(1000L * 60 * 10); // 10분;

new Thread(
() -> {
try {
emitter.send(progress(10, "분석 시작", null));

AnalysisReport savedReport =
analysisFlowService.uploadDocuments(
PathName.PROPERTYREGISTRY, file); // S3 업로드 + DB 저장(reportId 저장은 x)

emitter.send(progress(30, "s3 업로드 완료", null));

// ptAnalysisRequest 생성 (파일 제외하고)
GptAnalysisRequest gptAnalysisRequest =
new GptAnalysisRequest(
null, // file은 이미 처리했으므로 null
isMonthlyRent,
deposit,
monthlyRent,
detailAddress,
isExample);

AnalysisReportResponse analysisReportResponse =
analysisFlowService.processAnalysisReport(
savedReport.getReportId(), gptAnalysisRequest);

emitter.send(progress(60, "등기부등본 분석 완료", null));

emitter.send(progress(100, "분석리포트 결과 반환 완료", analysisReportResponse));
emitter.complete();

} catch (Exception e) {
try {
emitter.send(progress(-1, "에러 발생: " + e.getMessage(), null));
} catch (Exception ignore) {
}
emitter.completeWithError(e);
}
})
.start();

return emitter;

/* AnalysisReport savedReport =
AnalysisReport savedReport =
analysisFlowService.uploadDocuments(PathName.PROPERTYREGISTRY, file); // S3 업로드 + DB 저장

// ptAnalysisRequest 생성 (파일 제외하고)
Expand All @@ -109,7 +61,7 @@ public SseEmitter getAnalysisReport(

AnalysisReportResponse analysisReportResponse =
analysisFlowService.processAnalysisReport(savedReport.getReportId(), gptAnalysisRequest);
return ResponseEntity.ok(BaseResponse.success("분석리포트 결과 반환 완료", analysisReportResponse));*/
return ResponseEntity.ok(BaseResponse.success("분석리포트 결과 반환 완료", analysisReportResponse));
}

@Operation(summary = "등기부등본 파일 삭제 API", description = "X버튼을 눌러 업로드한 등기부등본 문서를 삭제하는 API")
Expand Down