From 84f12556db4e5a86a660e945dbb6502b6dc57d6f Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 01:10:19 +0900 Subject: [PATCH 1/8] =?UTF-8?q?fix=20#143:=20PUBLIC=20->=20PRIVATE=20?= =?UTF-8?q?=EB=B0=A9=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD=20=EC=8B=9C?= =?UTF-8?q?=20password=EA=B0=80=20=EB=82=A8=EC=95=84=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ei/algobaroapi/domain/room/domain/Room.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java index dee2ca5..f789296 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java @@ -144,12 +144,20 @@ public void update(RoomUpdateRequestDto roomUpdateRequestDto) { && roomUpdateRequestDto.getTimeLimit() > 0) { this.timeLimit = roomUpdateRequestDto.getTimeLimit(); } + + if (isPublic()) { + this.password = ""; + } } public String getRoomShortUuid() { return this.roomUuid.split("-")[0]; } + public boolean isPublic() { + return this.roomAccessType == RoomAccessType.PUBLIC; + } + public boolean isRecruiting() { return this.roomStatus == RoomStatus.RECRUITING; } From 5615ef2300220fd67f1b572ec47797165d25b1a4 Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 01:10:44 +0900 Subject: [PATCH 2/8] =?UTF-8?q?refactor=20#143:=20room=20update=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=AA=85=ED=99=95=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/room/controller/RoomControllerDocImpl.java | 2 +- .../java/ei/algobaroapi/domain/room/service/RoomService.java | 2 +- .../ei/algobaroapi/domain/room/service/RoomServiceImpl.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java b/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java index 6308ea9..7b90f65 100644 --- a/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java +++ b/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java @@ -50,7 +50,7 @@ public RoomDetailResponseDto createRoom( @PatchMapping("/rooms/{roomShortUuid}") public RoomResponseDto updateRoomById(@PathVariable(name = "roomShortUuid") String roomShortUuid, @RequestBody @Valid RoomUpdateRequestDto roomUpdateRequestDto) { - return roomService.updateRoomByRoomId(roomShortUuid, roomUpdateRequestDto); + return roomService.updateRoomByShortUuid(roomShortUuid, roomUpdateRequestDto); } @Override diff --git a/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java b/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java index 70253ef..2c85544 100644 --- a/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java @@ -15,7 +15,7 @@ public interface RoomService { RoomDetailResponseDto createRoom(RoomCreateRequestDto roomCreateRequestDto, Member member); - RoomResponseDto updateRoomByRoomId(String roomShortUuid, + RoomResponseDto updateRoomByShortUuid(String roomShortUuid, RoomUpdateRequestDto roomUpdateRequestDto); RoomDetailResponseDto getRoomDetailShortUuid(String roomShortUuid); diff --git a/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java b/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java index 64c25ee..cbeadcf 100644 --- a/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java @@ -64,7 +64,7 @@ public RoomDetailResponseDto createRoom(RoomCreateRequestDto roomCreateRequestDt @Override @Transactional - public RoomResponseDto updateRoomByRoomId(String roomShortUuid, + public RoomResponseDto updateRoomByShortUuid(String roomShortUuid, RoomUpdateRequestDto roomUpdateRequestDto) { Room room = getRoomByShortUuid(roomShortUuid); @@ -107,7 +107,8 @@ public RoomDetailResponseDto startCodingTest(String roomShortUuid) { @Override @Transactional public void completeSolveHistory(String roomShortUuid) { - List solveHistoryList = solveHistoryService.getSolveHistoryListByRoomShortUuid(roomShortUuid); + List solveHistoryList = solveHistoryService.getSolveHistoryListByRoomShortUuid( + roomShortUuid); solveHistoryList.forEach(solveHistory -> { SolveStatus solveStatus = problemService.checkSolveResult( From 7158ac644a766c048424852b7963fe1aba597807 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Tue, 19 Mar 2024 10:16:09 +0900 Subject: [PATCH 3/8] =?UTF-8?q?mod=20#121:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EB=90=98=EC=A7=80=20=EC=95=8A=EC=95=84=20?= =?UTF-8?q?=ED=81=AC=EB=A1=A4=EB=A7=81=20=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EC=83=81=ED=83=9C=20=EC=8B=A4=ED=8C=A8?= =?UTF-8?q?=ED=95=9C=EA=B1=B8=EB=A1=9C=20=EC=B2=98=EB=A6=AC=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/problem/service/BojProblemServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a414c96..a7add1d 100644 --- a/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/problem/service/BojProblemServiceImpl.java @@ -97,7 +97,7 @@ public SolveStatus checkSolveResult(ProblemSolveRequest request) { answer = result.equals(CORRECT) ? SolveStatus.SUCCESS : SolveStatus.FAIL; } catch (IOException e) { - throw CrawlingAccessException.of(ProblemErrorCode.CRAWLING_NOT_ACCESS); + return SolveStatus.FAIL; } return answer; From 95d8101e0587d419bdcddfd5271d4feaf693e4be Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 10:40:04 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat=20#143:=20submitCode=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B8=B0=EB=8A=A5=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - submitCode: 제출한 코드를 데이터베이스에 저장 - submitCodeAndCompie: 테스트케이스 채점 및 제출 코드 데이터베이스에 저장 --- .../solve/service/BojSolveServiceImpl.java | 17 ++++++++++++++++- .../domain/solve/service/SolveService.java | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java b/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java index 6bcc83f..3fc7170 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java @@ -8,7 +8,9 @@ import ei.algobaroapi.domain.problem.service.ProblemService; import ei.algobaroapi.domain.solve.dto.BojTestCaseResult; import ei.algobaroapi.domain.solve.dto.request.BojCodeSubmissionRequest; +import ei.algobaroapi.domain.solve.dto.request.CodeSubmissionRequest; import ei.algobaroapi.domain.solve.dto.response.BojCodeSubmissionResponse; +import ei.algobaroapi.domain.solve.dto.response.CodeSubmissionResponse; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -24,7 +26,20 @@ public class BojSolveServiceImpl implements SolveService { private final SolveHistoryService solveHistoryService; @Override - public BojCodeSubmissionResponse submitCode(Long memberId, BojCodeSubmissionRequest request) { + public CodeSubmissionResponse submitCode(Long memberId, CodeSubmissionRequest request) { + solveHistoryService.updateSolveHistoryCode( + memberId, + request.getRoomShortUuid(), + request.getLanguage(), + request.getCode() + ); + + return CodeSubmissionResponse.of(request.getCode()); + } + + @Override + public BojCodeSubmissionResponse submitCodeAndCompile(Long memberId, + BojCodeSubmissionRequest request) { List problemTestCases = problemService.getProblemTestCases( ProblemFindRequest.builder() .problemLink(request.getProblemLink()) diff --git a/src/main/java/ei/algobaroapi/domain/solve/service/SolveService.java b/src/main/java/ei/algobaroapi/domain/solve/service/SolveService.java index 19f20ce..8b81c41 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/service/SolveService.java +++ b/src/main/java/ei/algobaroapi/domain/solve/service/SolveService.java @@ -1,9 +1,13 @@ package ei.algobaroapi.domain.solve.service; import ei.algobaroapi.domain.solve.dto.request.BojCodeSubmissionRequest; +import ei.algobaroapi.domain.solve.dto.request.CodeSubmissionRequest; import ei.algobaroapi.domain.solve.dto.response.BojCodeSubmissionResponse; +import ei.algobaroapi.domain.solve.dto.response.CodeSubmissionResponse; public interface SolveService { - BojCodeSubmissionResponse submitCode(Long memberId, BojCodeSubmissionRequest request); + CodeSubmissionResponse submitCode(Long memberId, CodeSubmissionRequest request); + + BojCodeSubmissionResponse submitCodeAndCompile(Long memberId, BojCodeSubmissionRequest request); } From aed3675eb5c873559e1b1b38e70f68fb910e7e1c Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 10:40:59 +0900 Subject: [PATCH 5/8] =?UTF-8?q?mod=20#143:=20submissionCode=20API=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solve/controller/SolveController.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java b/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java index 8f9c85b..d572ecf 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java +++ b/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java @@ -3,8 +3,10 @@ import ei.algobaroapi.domain.member.domain.Member; import ei.algobaroapi.domain.solve.domain.SolveHistory; import ei.algobaroapi.domain.solve.dto.request.BojCodeSubmissionRequest; +import ei.algobaroapi.domain.solve.dto.request.CodeSubmissionRequest; import ei.algobaroapi.domain.solve.dto.request.SolveHistoryListFindRequest; import ei.algobaroapi.domain.solve.dto.response.BojCodeSubmissionResponse; +import ei.algobaroapi.domain.solve.dto.response.CodeSubmissionResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryDetailResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryResponse; import ei.algobaroapi.domain.solve.dto.response.SolveResultResponse; @@ -35,13 +37,23 @@ public class SolveController implements SolveControllerDoc { @Override @PostMapping("/solves/submission") @PreAuthorize("hasRole('ROLE_USER')") - public BojCodeSubmissionResponse submissionCode( + public CodeSubmissionResponse submissionCode( @AuthenticationPrincipal Member member, - @RequestBody @Valid BojCodeSubmissionRequest request + @RequestBody @Valid CodeSubmissionRequest request ) { return solveService.submitCode(member.getId(), request); } + @Override + @PostMapping("/solves/submissionAndCompile") + @PreAuthorize("hasRole('ROLE_USER')") + public BojCodeSubmissionResponse submissionCodeAndCompile( + @AuthenticationPrincipal Member member, + @RequestBody @Valid BojCodeSubmissionRequest request + ) { + return solveService.submitCodeAndCompile(member.getId(), request); + } + @Override @GetMapping("/solves/history") @PreAuthorize("hasRole('ROLE_USER')") @@ -64,7 +76,8 @@ public SolveHistoryDetailResponse getHistoryDetail( @Override @GetMapping("/solves/result/{roomShortUuid}") - public SolveResultResponse getSolveResultInRoom(@PathVariable("roomShortUuid") String roomShortUuid) { + public SolveResultResponse getSolveResultInRoom( + @PathVariable("roomShortUuid") String roomShortUuid) { return solveHistoryService.getSolveResultInRoom(roomShortUuid); } } From 66c3a596008799b86faf859e07dbb099d1961cfc Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 10:41:08 +0900 Subject: [PATCH 6/8] =?UTF-8?q?docs=20#143:=20submissionCode=20API=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/swaggerdoc/SolveControllerDoc.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/SolveControllerDoc.java b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/SolveControllerDoc.java index 647107c..d90d437 100644 --- a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/SolveControllerDoc.java +++ b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/SolveControllerDoc.java @@ -3,8 +3,10 @@ import ei.algobaroapi.domain.member.domain.Member; import ei.algobaroapi.domain.solve.domain.SolveHistory; import ei.algobaroapi.domain.solve.dto.request.BojCodeSubmissionRequest; +import ei.algobaroapi.domain.solve.dto.request.CodeSubmissionRequest; import ei.algobaroapi.domain.solve.dto.request.SolveHistoryListFindRequest; import ei.algobaroapi.domain.solve.dto.response.BojCodeSubmissionResponse; +import ei.algobaroapi.domain.solve.dto.response.CodeSubmissionResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryDetailResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryResponse; import ei.algobaroapi.domain.solve.dto.response.SolveResultResponse; @@ -20,7 +22,11 @@ public interface SolveControllerDoc { @Operation(summary = "코드 제출", description = "문제 코드를 제출합니다.") @ApiResponse(responseCode = "201", description = "코드 제출 성공") - BojCodeSubmissionResponse submissionCode(Member member, BojCodeSubmissionRequest request); + CodeSubmissionResponse submissionCode(Member member, CodeSubmissionRequest request); + + @Operation(summary = "코드 제출 및 테스트 케이스 컴파일", description = "문제 코드를 제출합니다.") + @ApiResponse(responseCode = "201", description = "코드 제출 성공") + BojCodeSubmissionResponse submissionCodeAndCompile(Member member, BojCodeSubmissionRequest request); @Operation(summary = "문제 풀이 히스토리 리스트 조회", description = "문제 풀이 히스토리를 상세 조회합니다.") @ApiResponse(responseCode = "200", description = "문제 풀이 히스토리 리스트 조회 성공") From 55ef9aed8386d395f1829546d9adf9ac952f5d6d Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 10:41:41 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat=20#143:=20submitCode=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=9A=94=EC=B2=AD/=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/CodeSubmissionRequest.java | 20 +++++++++++++++++++ .../dto/response/CodeSubmissionResponse.java | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java create mode 100644 src/main/java/ei/algobaroapi/domain/solve/dto/response/CodeSubmissionResponse.java diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java b/src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java new file mode 100644 index 0000000..12e4b2c --- /dev/null +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java @@ -0,0 +1,20 @@ +package ei.algobaroapi.domain.solve.dto.request; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; + +@Schema(description = "코드 제출 요청") +@Getter +@Builder +public class CodeSubmissionRequest { + + @Schema(description = "방 식별 값", example = "123e4567") + private String roomShortUuid; + + @Schema(description = "코드 실행 언어\n\npython - python3\n\njavascript - nodejs\n\njava - java\n\nc++ - cpp", example = "java") + private String language; + + @Schema(description = "코드 실행 코드", example = "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] input = br.readLine().split(\" \");\n int a = Integer.parseInt(input[0]);\n int b = Integer.parseInt(input[1]);\n System.out.println(a + b);\n }\n}") + private String code; +} diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/response/CodeSubmissionResponse.java b/src/main/java/ei/algobaroapi/domain/solve/dto/response/CodeSubmissionResponse.java new file mode 100644 index 0000000..eae6a6d --- /dev/null +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/response/CodeSubmissionResponse.java @@ -0,0 +1,19 @@ +package ei.algobaroapi.domain.solve.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Schema(description = "코드 제출 응답 결과") +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public class CodeSubmissionResponse { + + @Schema(description = "제출 코드", example = "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] input = br.readLine().split(\" \");\n int a = Integer.parseInt(input[0]);\n int b = Integer.parseInt(input[1]);\n System.out.println(a + b);\n }\n}") + private final String submissionCode; + + public static CodeSubmissionResponse of(String submissionCode) { + return new CodeSubmissionResponse(submissionCode); + } +} From dcc282d217e8c67983c25f75ae455795ac5510ba Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Tue, 19 Mar 2024 11:08:47 +0900 Subject: [PATCH 8/8] =?UTF-8?q?refactor=20#143:=20API=20URL=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD(=EC=B9=B4=EB=A9=9C=EC=BC=80=EC=9D=B4=EC=8A=A4=20-=20d?= =?UTF-8?q?ash)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ei/algobaroapi/domain/solve/controller/SolveController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java b/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java index d572ecf..7b4914f 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java +++ b/src/main/java/ei/algobaroapi/domain/solve/controller/SolveController.java @@ -45,7 +45,7 @@ public CodeSubmissionResponse submissionCode( } @Override - @PostMapping("/solves/submissionAndCompile") + @PostMapping("/solves/submission-and-compile") @PreAuthorize("hasRole('ROLE_USER')") public BojCodeSubmissionResponse submissionCodeAndCompile( @AuthenticationPrincipal Member member,