Skip to content

Commit

Permalink
Merge pull request #155 from 1e5i-Shark/dev
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
GiHoo authored Mar 19, 2024
2 parents 33fd123 + 2ff527c commit 957a898
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public void startCodingTest(String roomShortUuid, Long memberId) {

@Override
public void endCodingTest(String roomShortUuid, Long memberId) {
checkMemberIsHost(roomShortUuid, memberId);

roomService.completeSolveHistory(roomShortUuid);
messageService.sendMessage(roomShortUuid, MessageResponse.endCoding(memberId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ RoomResponseDto updateRoomByShortUuid(String roomShortUuid,
RoomDetailResponseDto getRoomDetailShortUuid(String roomShortUuid);

RoomDetailResponseDto startCodingTest(String roomShortUuid);

void completeSolveHistory(String roomShortUuid);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ei.algobaroapi.domain.room.service;

import ei.algobaroapi.domain.member.domain.Member;
import ei.algobaroapi.domain.problem.dto.request.ProblemSolveRequest;
import ei.algobaroapi.domain.problem.service.ProblemService;
import ei.algobaroapi.domain.room.domain.Room;
import ei.algobaroapi.domain.room.domain.RoomRepository;
import ei.algobaroapi.domain.room.dto.request.RoomCreateRequestDto;
Expand All @@ -15,8 +13,6 @@
import ei.algobaroapi.domain.room_member.domain.RoomMember;
import ei.algobaroapi.domain.room_member.dto.response.RoomMemberResponseDto;
import ei.algobaroapi.domain.room_member.service.RoomMemberService;
import ei.algobaroapi.domain.solve.domain.SolveHistory;
import ei.algobaroapi.domain.solve.domain.SolveStatus;
import ei.algobaroapi.domain.solve.service.SolveHistoryService;
import ei.algobaroapi.global.dto.PageResponse;
import java.util.List;
Expand All @@ -34,7 +30,6 @@ public class RoomServiceImpl implements RoomService {
private final RoomRepository roomRepository;
private final RoomMemberService roomMemberService;
private final SolveHistoryService solveHistoryService;
private final ProblemService problemService;

@Override
public PageResponse<Room, RoomResponseDto> getAllRooms(RoomListRequestDto request) {
Expand Down Expand Up @@ -104,24 +99,6 @@ public RoomDetailResponseDto startCodingTest(String roomShortUuid) {
roomMembers.stream().map(RoomMemberResponseDto::of).toList());
}

@Override
@Transactional
public void completeSolveHistory(String roomShortUuid) {
List<SolveHistory> solveHistoryList = solveHistoryService.getSolveHistoryListByRoomShortUuid(
roomShortUuid);

solveHistoryList.forEach(solveHistory -> {
SolveStatus solveStatus = problemService.checkSolveResult(
ProblemSolveRequest.builder()
.problemLink(solveHistory.getProblemLink())
.userBojId(solveHistory.getMember().getBojId())
.build()
);

solveHistory.complete(solveStatus);
});
}

private List<RoomMemberResponseDto> getRoomMembersByRoomId(Long roomId) {
return roomMemberService.getRoomMembersByRoomId(roomId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ public SolveHistory(Member member, String roomUuid, String problemLink) {
this.problemPlatform = ProblemPlatform.BOJ;
}

public void complete(SolveStatus solveStatus) {
this.solveStatus = solveStatus;
this.endAt = LocalDateTime.now();
}

public void updateCodeAndLanguage(String code, String language) {
public void updateCodeAndLanguageAndSolveStatus(String code, String language, String solveStatus) {
this.inputCode = code;
this.codeLanguage = language;
this.solveStatus = SolveStatus.valueOf(solveStatus);
this.endAt = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class BojCodeSubmissionRequest {
@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;

@Schema(description = "코드 실행 결과", example = "SUCCESS / FAIL")
private String solveStatus;

@Schema(description = "문제 링크", example = "https://www.acmicpc.net/problem/1000")
private String problemLink;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public class CodeSubmissionRequest {

@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;

@Schema(description = "코드 실행 결과", example = "SUCCESS / FAIL")
private String solveStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public CodeSubmissionResponse submitCode(Long memberId, CodeSubmissionRequest re
memberId,
request.getRoomShortUuid(),
request.getLanguage(),
request.getCode()
request.getCode(),
request.getSolveStatus()
);

return CodeSubmissionResponse.of(request.getCode());
Expand All @@ -56,7 +57,8 @@ public BojCodeSubmissionResponse submitCodeAndCompile(Long memberId,
memberId,
request.getRoomShortUuid(),
request.getLanguage(),
request.getCode()
request.getCode(),
request.getSolveStatus()
);

return BojCodeSubmissionResponse.of(testCaseResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PageResponse<SolveHistory, SolveHistoryResponse> getHistoryList(

SolveHistoryDetailResponse getHistoryDetail(Long memberId, Long solveId);

void updateSolveHistoryCode(Long memberId, String roomShortUuid, String language, String code);
void updateSolveHistoryCode(Long memberId, String roomShortUuid, String language, String code, String solveStatus);

SolveResultResponse getSolveResultInRoom(String roomShortUuid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ public void updateSolveHistoryCode(
Long memberId,
String roomShortUuid,
String language,
String code
String code,
String solveStatus
) {
Member findMember = memberService.getMemberById(memberId);
SolveHistory findSolveHistory = getSolveHistoryByMemberAndRoomUuid(
roomShortUuid,
findMember
);

findSolveHistory.updateCodeAndLanguage(code, language);
findSolveHistory.updateCodeAndLanguageAndSolveStatus(code, language, solveStatus);
}

private SolveHistory getSolveHistoryByMemberAndRoomUuid(
Expand Down

0 comments on commit 957a898

Please sign in to comment.