From 770cbb855d289c9a05dbb10eeb9d1be7b13b7ef6 Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Thu, 14 Mar 2024 02:42:37 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AC=B8=EC=A0=9C=20=ED=81=AC=EB=A1=A4?= =?UTF-8?q?=EB=A7=81=20=EC=9A=94=EC=B2=AD=20=EC=A0=95=EB=B3=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD(RequestBody=20->=20RequestParam)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/problem/controller/ProblemController.java | 5 +++-- .../domain/problem/service/BojProblemServiceImpl.java | 4 ++-- .../algobaroapi/domain/problem/service/ProblemService.java | 2 +- .../global/config/swaggerdoc/ProblemControllerDoc.java | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/problem/controller/ProblemController.java b/src/main/java/ei/algobaroapi/domain/problem/controller/ProblemController.java index 30c4686d..f5abe1d5 100644 --- a/src/main/java/ei/algobaroapi/domain/problem/controller/ProblemController.java +++ b/src/main/java/ei/algobaroapi/domain/problem/controller/ProblemController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -20,7 +21,7 @@ public class ProblemController implements ProblemControllerDoc { @Override @GetMapping("/problems/html") - public ProblemHtmlResponse getProblemHtml(@RequestBody @Valid ProblemFindRequest request) { - return bojProblemService.getProblemInfoHtml(request); + public ProblemHtmlResponse getProblemHtml(@RequestParam String problemLink) { + return bojProblemService.getProblemInfoHtml(problemLink); } } diff --git a/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java b/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java index 542a7f2c..933c6fc7 100644 --- a/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java @@ -27,10 +27,10 @@ public class BojProblemServiceImpl implements ProblemService { private static final String CORRECT = "맞았습니다!!"; @Override - public ProblemHtmlResponse getProblemInfoHtml(ProblemFindRequest request) { + public ProblemHtmlResponse getProblemInfoHtml(String problemLink) { try { return ProblemHtmlResponse.of( - Jsoup.connect(request.getProblemLink()).get().outerHtml()); + Jsoup.connect(problemLink).get().outerHtml()); } catch (IOException e) { throw CrawlingAccessException.of(ProblemErrorCode.CRAWLING_NOT_ACCESS); } diff --git a/src/main/java/ei/algobaroapi/domain/problem/service/ProblemService.java b/src/main/java/ei/algobaroapi/domain/problem/service/ProblemService.java index 5874532e..4f16eb53 100644 --- a/src/main/java/ei/algobaroapi/domain/problem/service/ProblemService.java +++ b/src/main/java/ei/algobaroapi/domain/problem/service/ProblemService.java @@ -9,7 +9,7 @@ public interface ProblemService { - ProblemHtmlResponse getProblemInfoHtml(ProblemFindRequest request); + ProblemHtmlResponse getProblemInfoHtml(String problemLink); List getProblemTestCases(ProblemFindRequest request); diff --git a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/ProblemControllerDoc.java b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/ProblemControllerDoc.java index f2330036..2ab074a3 100644 --- a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/ProblemControllerDoc.java +++ b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/ProblemControllerDoc.java @@ -3,6 +3,7 @@ import ei.algobaroapi.domain.problem.dto.request.ProblemFindRequest; import ei.algobaroapi.domain.problem.dto.response.ProblemHtmlResponse; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; @Tag(name = "Problem", description = "문제 관련 API") @@ -10,5 +11,6 @@ public interface ProblemControllerDoc { @Operation(summary = "문제 정보 조회", description = "문제 사이트의 내용을 HTML로 가져옵니다.") - ProblemHtmlResponse getProblemHtml(ProblemFindRequest request); + @ApiResponse(responseCode = "200", description = "문제 정보 조회 성공") + ProblemHtmlResponse getProblemHtml(String problemLink); }