From 3b5553e53060f2b7a76183360aeaaab2001f017e Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 08:58:17 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat=20#150:=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=EC=97=90=20=EC=8A=A4?= =?UTF-8?q?=EC=BC=80=EC=A4=84=EB=A7=81=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ei/algobaroapi/AlgobaroApiApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/ei/algobaroapi/AlgobaroApiApplication.java b/src/main/java/ei/algobaroapi/AlgobaroApiApplication.java index 39a656fc..cc01e562 100644 --- a/src/main/java/ei/algobaroapi/AlgobaroApiApplication.java +++ b/src/main/java/ei/algobaroapi/AlgobaroApiApplication.java @@ -2,7 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; +@EnableScheduling @SpringBootApplication public class AlgobaroApiApplication { From e67ba3c052e0e26f531a9fc974c58f27ae0973cd Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 08:59:00 +0900 Subject: [PATCH 02/14] =?UTF-8?q?feat=20#150:=20=EC=8B=9C=EC=9E=91=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20+=20=EC=A7=84=ED=96=89=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20+=20=EC=9D=BC=EC=A0=95=20=EC=8B=9C=EA=B0=84=20<=20?= =?UTF-8?q?=ED=98=84=EC=9E=AC=20=EC=8B=9C=EA=B0=84=EC=97=90=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=ED=95=98=EB=8A=94=20room=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ei/algobaroapi/domain/room/domain/RoomRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/ei/algobaroapi/domain/room/domain/RoomRepository.java b/src/main/java/ei/algobaroapi/domain/room/domain/RoomRepository.java index 0848a8d6..5de75b8a 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/RoomRepository.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/RoomRepository.java @@ -1,5 +1,7 @@ package ei.algobaroapi.domain.room.domain; +import java.time.LocalDateTime; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -10,4 +12,10 @@ public interface RoomRepository extends JpaRepository, RoomRepositor @Query("SELECT r FROM Room r WHERE r.roomUuid LIKE CONCAT(:roomShortUuid, '%')") Optional findByRoomUuidStartingWith(String roomShortUuid); + + @Query(value = + "SELECT * FROM room WHERE DATE_ADD(start_at, INTERVAL time_limit + :timeOffsetMinutes MINUTE) < :now", + nativeQuery = true + ) + List findListEndAtBefore(LocalDateTime now, int timeOffsetMinutes); } From 03ab535e519b10feb2106f9c9f048dbdae2512a7 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 10:05:47 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat=20#150:=20=EB=B0=A9=20=EC=A2=85?= =?UTF-8?q?=EB=A3=8C=20=EC=98=88=EC=A0=95=20=EC=8B=9C=EA=B0=84=20=EC=9D=B4?= =?UTF-8?q?=ED=9B=84=2030=EB=B6=84=EC=9D=B4=20=EC=A7=80=EB=82=9C=20?= =?UTF-8?q?=EB=B0=A9=EC=97=90=20=EB=8C=80=ED=95=B4=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=8A=A4=EC=BC=80=EC=A4=84=EB=9F=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/service/RoomSchedulerService.java | 6 +++ .../service/RoomSchedulerServiceImpl.java | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerService.java create mode 100644 src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerServiceImpl.java diff --git a/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerService.java b/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerService.java new file mode 100644 index 00000000..d0f9f94f --- /dev/null +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerService.java @@ -0,0 +1,6 @@ +package ei.algobaroapi.domain.room.service; + +public interface RoomSchedulerService { + + void deleteRoomScheduler(); +} diff --git a/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerServiceImpl.java b/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerServiceImpl.java new file mode 100644 index 00000000..3f084099 --- /dev/null +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomSchedulerServiceImpl.java @@ -0,0 +1,42 @@ +package ei.algobaroapi.domain.room.service; + +import ei.algobaroapi.domain.room.domain.Room; +import ei.algobaroapi.domain.room.domain.RoomRepository; +import ei.algobaroapi.domain.room_member.domain.RoomMemberRepository; +import java.time.LocalDateTime; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@RequiredArgsConstructor +public class RoomSchedulerServiceImpl implements RoomSchedulerService { + + private static final int DELETE_ROOM_TIME_OFFSET_MINUTES = 30; + private final RoomRepository roomRepository; + private final RoomMemberRepository roomMemberRepository; + + @Override + @Scheduled(cron = "0/10 * * * * *") + @Transactional + public void deleteRoomScheduler() { + List toDeleteRooms = findExpiredRooms(); + deleteRoomsAndMembers(toDeleteRooms); + } + + private List findExpiredRooms() { + return roomRepository.findListEndAtBefore( + LocalDateTime.now(), + DELETE_ROOM_TIME_OFFSET_MINUTES + ); + } + + private void deleteRoomsAndMembers(List toDeleteRooms) { + for (Room toDeleteRoom : toDeleteRooms) { + roomMemberRepository.deleteAll(toDeleteRoom.getRoomMembers()); + } + roomRepository.deleteAll(toDeleteRooms); + } +} From 9c5c25f5e4584cd8e9fc09451ef50d2dbc41e451 Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Wed, 20 Mar 2024 10:54:40 +0900 Subject: [PATCH 04/14] =?UTF-8?q?feat=20#157:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=9C=EC=B6=9C=20=EC=9A=94=EC=B2=AD=EC=97=90=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20=EC=9D=B4=EC=9C=A0=20=ED=95=84=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/solve/dto/request/BojCodeSubmissionRequest.java | 6 +++++- .../domain/solve/dto/request/CodeSubmissionRequest.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/request/BojCodeSubmissionRequest.java b/src/main/java/ei/algobaroapi/domain/solve/dto/request/BojCodeSubmissionRequest.java index 010570cc..8b95a564 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/dto/request/BojCodeSubmissionRequest.java +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/request/BojCodeSubmissionRequest.java @@ -1,5 +1,6 @@ package ei.algobaroapi.domain.solve.dto.request; +import ei.algobaroapi.domain.solve.domain.SolveStatus; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; @@ -19,7 +20,10 @@ public class BojCodeSubmissionRequest { private String code; @Schema(description = "코드 실행 결과", example = "SUCCESS / FAIL") - private String solveStatus; + private SolveStatus solveStatus; + + @Schema(description = "실패 이유", example = "MEMORY_LIMIT, TIME_LIMIT, ETC") + private String failureReason; @Schema(description = "문제 링크", example = "https://www.acmicpc.net/problem/1000") private String problemLink; 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 index c7ca6e82..b40b0c4f 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/request/CodeSubmissionRequest.java @@ -1,5 +1,6 @@ package ei.algobaroapi.domain.solve.dto.request; +import ei.algobaroapi.domain.solve.domain.SolveStatus; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; @@ -19,5 +20,8 @@ public class CodeSubmissionRequest { private String code; @Schema(description = "코드 실행 결과", example = "SUCCESS / FAIL") - private String solveStatus; + private SolveStatus solveStatus; + + @Schema(description = "실패 이유", example = "MEMORY_LIMIT, TIME_LIMIT, ETC") + private String failureReason; } From da2a989d3b3342e24f6ca70278edac16d1c6519e Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Wed, 20 Mar 2024 10:55:15 +0900 Subject: [PATCH 05/14] =?UTF-8?q?mod=20#157:=20SolveHistory=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20failureReason=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ei/algobaroapi/domain/solve/domain/SolveHistory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java b/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java index 8a0714ea..f87d6379 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java +++ b/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java @@ -52,6 +52,9 @@ public class SolveHistory extends BaseEntity { @Column(name = "solve_status", nullable = false) private SolveStatus solveStatus; + @Column(name = "failure_reason") + private String failureReason; + @Column(name = "problem_link", nullable = false) private String problemLink; @@ -68,14 +71,16 @@ public SolveHistory(Member member, String roomUuid, String problemLink) { this.startAt = LocalDateTime.now(); this.endAt = null; this.solveStatus = SolveStatus.FAIL; + this.failureReason = "미제출"; this.problemLink = problemLink; this.problemPlatform = ProblemPlatform.BOJ; } - public void updateCodeAndLanguageAndSolveStatus(String code, String language, String solveStatus) { + public void updateCodeAndLanguageAndSolveStatus(String code, String language, SolveStatus solveStatus, String failureReason) { this.inputCode = code; this.codeLanguage = language; - this.solveStatus = SolveStatus.valueOf(solveStatus); + this.solveStatus = solveStatus; + this.failureReason = failureReason; this.endAt = LocalDateTime.now(); } } From 99a73b1aa2c07ce0e7099eddde5324488b076c1a Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Wed, 20 Mar 2024 10:59:27 +0900 Subject: [PATCH 06/14] =?UTF-8?q?mod=20#157:=20response=20dto=EC=97=90=20f?= =?UTF-8?q?ailureReason=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/solve/dto/response/SolveHistoryDetailResponse.java | 4 ++++ .../domain/solve/dto/response/SolveHistoryResponse.java | 4 ++++ .../ei/algobaroapi/domain/solve/dto/response/SolveResult.java | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryDetailResponse.java b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryDetailResponse.java index 6cd7b5b8..74b821e2 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryDetailResponse.java +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryDetailResponse.java @@ -26,6 +26,9 @@ public class SolveHistoryDetailResponse { @Schema(description = "풀이 결과", example = "SUCCESS") private final String solveStatus; + @Schema(description = "실패 이유", example = "MEMORY_LIMIT / TIME_LIMIT / ETC / NULL") + private final String failureReason; + @Schema(description = "풀이 시간", example = "2024-01-01T00:00:00") private final String solvedAt; @@ -42,6 +45,7 @@ public static SolveHistoryDetailResponse of(SolveHistory solveHistory) { solveHistory.getCodeLanguage(), solveHistory.getInputCode(), solveHistory.getSolveStatus().name(), + solveHistory.getFailureReason(), solveHistory.getStartAt().toString(), solveHistory.getProblemPlatform().name(), solveHistory.getProblemLink() diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryResponse.java b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryResponse.java index 420685bb..d2838159 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryResponse.java +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveHistoryResponse.java @@ -23,6 +23,9 @@ public class SolveHistoryResponse { @Schema(description = "풀이 결과", example = "SUCCESS") private final String solveStatus; + @Schema(description = "실패 이유", example = "MEMORY_LIMIT / TIME_LIMIT / ETC / NULL") + private final String failureReason; + @Schema(description = "풀이 시간", example = "2024-01-01T00:00:00") private final String solvedAt; @@ -35,6 +38,7 @@ public static SolveHistoryResponse of(SolveHistory solveHistory) { solveHistory.getRoomUuid(), solveHistory.getCodeLanguage(), solveHistory.getSolveStatus().name(), + solveHistory.getFailureReason(), solveHistory.getStartAt().toString(), solveHistory.getProblemLink() ); diff --git a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveResult.java b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveResult.java index 5a5ce71c..4c7f0704 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveResult.java +++ b/src/main/java/ei/algobaroapi/domain/solve/dto/response/SolveResult.java @@ -24,4 +24,7 @@ public class SolveResult { @Schema(description = "풀이 결과", example = "SUCCESS") private final SolveStatus solveStatus; + + @Schema(description = "실패 이유", example = "MEMORY_LIMIT / TIME_LIMIT / ETC / NULL") + private final String failureReason; } From c8cfcf0e105b0c6b4ebbd4c28b9c62fe1c42c085 Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Wed, 20 Mar 2024 10:59:58 +0900 Subject: [PATCH 07/14] =?UTF-8?q?mod=20#157:=20failureReason=20param=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/solve/service/BojSolveServiceImpl.java | 6 ++++-- .../domain/solve/service/SolveHistoryService.java | 3 ++- .../domain/solve/service/SolveHistoryServiceImpl.java | 6 ++++-- 3 files changed, 10 insertions(+), 5 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 3c96dbe2..df034062 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/solve/service/BojSolveServiceImpl.java @@ -32,7 +32,8 @@ public CodeSubmissionResponse submitCode(Long memberId, CodeSubmissionRequest re request.getRoomShortUuid(), request.getLanguage(), request.getCode(), - request.getSolveStatus() + request.getSolveStatus(), + request.getFailureReason() ); return CodeSubmissionResponse.of(request.getCode()); @@ -58,7 +59,8 @@ public BojCodeSubmissionResponse submitCodeAndCompile(Long memberId, request.getRoomShortUuid(), request.getLanguage(), request.getCode(), - request.getSolveStatus() + request.getSolveStatus(), + request.getFailureReason() ); return BojCodeSubmissionResponse.of(testCaseResults); diff --git a/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryService.java b/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryService.java index 8e2d04d1..1da56f1a 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryService.java +++ b/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryService.java @@ -1,6 +1,7 @@ package ei.algobaroapi.domain.solve.service; import ei.algobaroapi.domain.solve.domain.SolveHistory; +import ei.algobaroapi.domain.solve.domain.SolveStatus; import ei.algobaroapi.domain.solve.dto.request.SolveHistoryListFindRequest; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryDetailResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryResponse; @@ -18,7 +19,7 @@ PageResponse getHistoryList( SolveHistoryDetailResponse getHistoryDetail(Long memberId, Long solveId); - void updateSolveHistoryCode(Long memberId, String roomShortUuid, String language, String code, String solveStatus); + void updateSolveHistoryCode(Long memberId, String roomShortUuid, String language, String code, SolveStatus solveStatus, String failureReason); SolveResultResponse getSolveResultInRoom(String roomShortUuid); diff --git a/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryServiceImpl.java b/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryServiceImpl.java index 17062f6b..6a010189 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/solve/service/SolveHistoryServiceImpl.java @@ -4,6 +4,7 @@ import ei.algobaroapi.domain.member.service.MemberService; import ei.algobaroapi.domain.solve.domain.SolveHistory; import ei.algobaroapi.domain.solve.domain.SolveHistoryRepository; +import ei.algobaroapi.domain.solve.domain.SolveStatus; import ei.algobaroapi.domain.solve.dto.request.SolveHistoryListFindRequest; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryDetailResponse; import ei.algobaroapi.domain.solve.dto.response.SolveHistoryResponse; @@ -59,7 +60,8 @@ public void updateSolveHistoryCode( String roomShortUuid, String language, String code, - String solveStatus + SolveStatus solveStatus, + String failureReason ) { Member findMember = memberService.getMemberById(memberId); SolveHistory findSolveHistory = getSolveHistoryByMemberAndRoomUuid( @@ -67,7 +69,7 @@ public void updateSolveHistoryCode( findMember ); - findSolveHistory.updateCodeAndLanguageAndSolveStatus(code, language, solveStatus); + findSolveHistory.updateCodeAndLanguageAndSolveStatus(code, language, solveStatus, failureReason); } private SolveHistory getSolveHistoryByMemberAndRoomUuid( From 10979397a002a373e9ea899e0f60e0274777e83d Mon Sep 17 00:00:00 2001 From: kimnamgyu Date: Wed, 20 Mar 2024 11:08:30 +0900 Subject: [PATCH 08/14] =?UTF-8?q?refactor=20#157:=20=EB=AF=B8=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=20=ED=95=84=EB=93=9C=20=EC=98=81=EC=96=B4=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ei/algobaroapi/domain/solve/domain/SolveHistory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java b/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java index f87d6379..f859a0b7 100644 --- a/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java +++ b/src/main/java/ei/algobaroapi/domain/solve/domain/SolveHistory.java @@ -71,7 +71,7 @@ public SolveHistory(Member member, String roomUuid, String problemLink) { this.startAt = LocalDateTime.now(); this.endAt = null; this.solveStatus = SolveStatus.FAIL; - this.failureReason = "미제출"; + this.failureReason = "UNSUBMITTED"; this.problemLink = problemLink; this.problemPlatform = ProblemPlatform.BOJ; } From 74f04faa4551a33eeef88aa16a1076674346b04d Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 10:49:32 +0900 Subject: [PATCH 09/14] =?UTF-8?q?fix=20#158:=20=EB=B0=A9=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=EC=8B=9C=20=EC=8B=9C=EC=9E=91=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= 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 | 1 + 1 file changed, 1 insertion(+) 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 f7892969..c5df9d7b 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java @@ -176,5 +176,6 @@ public boolean isHeadCountFull(int roomSize) { public void updateRoomStatusRunning() { this.roomStatus = RoomStatus.RUNNING; + this.startAt = LocalDateTime.now(); } } From 85aa1097d93940ddec07113b0ebcbe494a69dcc6 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 10:49:56 +0900 Subject: [PATCH 10/14] =?UTF-8?q?mod=20#158:=20=EB=B0=A9=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=ED=92=80=EC=9D=B4=20=EC=A2=85=EB=A3=8C?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=84=20=EB=B0=98=ED=99=98=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/room/dto/response/RoomDetailResponseDto.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/ei/algobaroapi/domain/room/dto/response/RoomDetailResponseDto.java b/src/main/java/ei/algobaroapi/domain/room/dto/response/RoomDetailResponseDto.java index f057f1e7..30854bf0 100644 --- a/src/main/java/ei/algobaroapi/domain/room/dto/response/RoomDetailResponseDto.java +++ b/src/main/java/ei/algobaroapi/domain/room/dto/response/RoomDetailResponseDto.java @@ -47,6 +47,9 @@ public class RoomDetailResponseDto { @Schema(description = "타이머(Minute)", example = "20") private Integer timeLimit; + @Schema(description = "방 종료 예정 시간", example = "2024-03-04T00:45:18") + private String endTime; + @Schema(description = "방 short UUID", example = "2ad2e9db") private String roomShortUuid; @@ -88,6 +91,9 @@ public static RoomDetailResponseDto of(Room room, List ro room.getTags(), room.getTimeLimit(), room.getRoomShortUuid(), + room.getStartAt() == null + ? null + : room.getStartAt().plusMinutes(room.getTimeLimit()).toString(), roomMembers ); } From 5a7098f116de05d2fbcd5f0bf1e46f058ed99ca1 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 10:53:13 +0900 Subject: [PATCH 11/14] =?UTF-8?q?fix=20#158:=20=EB=B0=A9=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=9C=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=20=EC=8B=9C=EA=B0=84=20=EB=B3=80=EB=8F=99=20?= =?UTF-8?q?=EB=B6=88=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= 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 | 5 ----- .../domain/room/dto/request/RoomUpdateRequestDto.java | 4 ---- 2 files changed, 9 deletions(-) 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 c5df9d7b..34285e64 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java @@ -102,11 +102,6 @@ public void update(RoomUpdateRequestDto roomUpdateRequestDto) { this.title = roomUpdateRequestDto.getTitle(); } - if (roomUpdateRequestDto.getStartAt() != null && roomUpdateRequestDto.getStartAt() - .isAfter(LocalDateTime.now())) { - this.startAt = roomUpdateRequestDto.getStartAt(); - } - if (roomUpdateRequestDto.getLanguages() != null && !roomUpdateRequestDto.getLanguages() .isEmpty()) { this.languages = roomUpdateRequestDto.getLanguages(); diff --git a/src/main/java/ei/algobaroapi/domain/room/dto/request/RoomUpdateRequestDto.java b/src/main/java/ei/algobaroapi/domain/room/dto/request/RoomUpdateRequestDto.java index 4ced8702..bac5286c 100644 --- a/src/main/java/ei/algobaroapi/domain/room/dto/request/RoomUpdateRequestDto.java +++ b/src/main/java/ei/algobaroapi/domain/room/dto/request/RoomUpdateRequestDto.java @@ -2,7 +2,6 @@ import ei.algobaroapi.domain.room.domain.RoomAccessType; import io.swagger.v3.oas.annotations.media.Schema; -import java.time.LocalDateTime; import java.util.List; import lombok.Builder; import lombok.Getter; @@ -15,9 +14,6 @@ public class RoomUpdateRequestDto { @Schema(description = "방 제목", example = "같이 푸실분~") private String title; - @Schema(description = "방 시작 시간", example = "2024-2-18T17:30:00") - private LocalDateTime startAt; - @Schema(description = "사용 가능 언어", example = "[\"JAVA\", \"C++\"]") private List languages; From 4065cc52da25eb1974064ecb4f5fc76eb9b056f5 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 11:05:43 +0900 Subject: [PATCH 12/14] =?UTF-8?q?fix=20#158:=20=EB=B0=A9=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=9C=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EC=B2=B4=ED=81=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/room/controller/RoomControllerDocImpl.java | 10 +++++++--- .../algobaroapi/domain/room/service/RoomService.java | 7 +++++-- .../domain/room/service/RoomServiceImpl.java | 8 ++++++-- .../global/config/swaggerdoc/RoomControllerDoc.java | 6 +++++- 4 files changed, 23 insertions(+), 8 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 7b90f652..4603b4ca 100644 --- a/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java +++ b/src/main/java/ei/algobaroapi/domain/room/controller/RoomControllerDocImpl.java @@ -48,9 +48,13 @@ public RoomDetailResponseDto createRoom( @Override @PatchMapping("/rooms/{roomShortUuid}") - public RoomResponseDto updateRoomById(@PathVariable(name = "roomShortUuid") String roomShortUuid, - @RequestBody @Valid RoomUpdateRequestDto roomUpdateRequestDto) { - return roomService.updateRoomByShortUuid(roomShortUuid, roomUpdateRequestDto); + @PreAuthorize("hasRole('USER')") + public RoomResponseDto updateRoomById( + @PathVariable(name = "roomShortUuid") String roomShortUuid, + @RequestBody @Valid RoomUpdateRequestDto roomUpdateRequestDto, + @AuthenticationPrincipal Member member + ) { + return roomService.updateRoomByShortUuid(roomShortUuid, roomUpdateRequestDto, member); } @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 ebe6cdb2..9b387d8d 100644 --- a/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomService.java @@ -15,8 +15,11 @@ public interface RoomService { RoomDetailResponseDto createRoom(RoomCreateRequestDto roomCreateRequestDto, Member member); - RoomResponseDto updateRoomByShortUuid(String roomShortUuid, - RoomUpdateRequestDto roomUpdateRequestDto); + RoomResponseDto updateRoomByShortUuid( + String roomShortUuid, + RoomUpdateRequestDto roomUpdateRequestDto, + Member member + ); 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 729aa093..f32f6da7 100644 --- a/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java +++ b/src/main/java/ei/algobaroapi/domain/room/service/RoomServiceImpl.java @@ -59,8 +59,12 @@ public RoomDetailResponseDto createRoom(RoomCreateRequestDto roomCreateRequestDt @Override @Transactional - public RoomResponseDto updateRoomByShortUuid(String roomShortUuid, - RoomUpdateRequestDto roomUpdateRequestDto) { + public RoomResponseDto updateRoomByShortUuid( + String roomShortUuid, + RoomUpdateRequestDto roomUpdateRequestDto, + Member member + ) { + roomMemberService.validateHost(roomShortUuid, member.getId()); Room room = getRoomByShortUuid(roomShortUuid); room.update(roomUpdateRequestDto); diff --git a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/RoomControllerDoc.java b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/RoomControllerDoc.java index 4aaf0835..cc0a569d 100644 --- a/src/main/java/ei/algobaroapi/global/config/swaggerdoc/RoomControllerDoc.java +++ b/src/main/java/ei/algobaroapi/global/config/swaggerdoc/RoomControllerDoc.java @@ -27,7 +27,11 @@ public interface RoomControllerDoc { @Operation(summary = "방 수정", description = "방 정보를 수정합니다.") @ApiResponse(responseCode = "200", description = "방 수정 성공") @ApiResponse(responseCode = "E03301", description = "수정하려는 방 정보를 찾지 못했습니다.") - RoomResponseDto updateRoomById(String roomShortUuid, RoomUpdateRequestDto roomUpdateRequestDto); + RoomResponseDto updateRoomById( + String roomShortUuid, + RoomUpdateRequestDto roomUpdateRequestDto, + Member member + ); @Operation(summary = "개별 방 정보 조회", description = "short UUID를 통해 방을 조회합니다.") @ApiResponse(responseCode = "200", description = "방 정보 조회 성공") From ffb15f6205059bf54899c27e109647cd3c325065 Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 11:08:41 +0900 Subject: [PATCH 13/14] =?UTF-8?q?refactor=20#158:=20=ED=95=A0=EB=8B=B9=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EC=83=9D=EC=84=B1=EC=9E=90=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 34285e64..d40a4324 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java @@ -76,7 +76,7 @@ public class Room extends BaseEntity { private String roomUuid; @OneToMany(mappedBy = "room", fetch = FetchType.LAZY) - private List roomMembers = new ArrayList<>(); + private List roomMembers; @Builder public Room(RoomStatus roomStatus, String title, List languages, LocalDateTime startAt, @@ -95,6 +95,8 @@ public Room(RoomStatus roomStatus, String title, List languages, LocalDa this.tags = tags; this.timeLimit = timeLimit; this.roomUuid = UUID.randomUUID().toString(); + + this.roomMembers = new ArrayList<>(); } public void update(RoomUpdateRequestDto roomUpdateRequestDto) { From aa1a509e5a1623fe374da8247f8219a9779855de Mon Sep 17 00:00:00 2001 From: hyoguoo Date: Wed, 20 Mar 2024 11:09:26 +0900 Subject: [PATCH 14/14] =?UTF-8?q?chore=20#158:=20warning=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=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 | 1 + 1 file changed, 1 insertion(+) 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 d40a4324..0a9a124b 100644 --- a/src/main/java/ei/algobaroapi/domain/room/domain/Room.java +++ b/src/main/java/ei/algobaroapi/domain/room/domain/Room.java @@ -79,6 +79,7 @@ public class Room extends BaseEntity { private List roomMembers; @Builder + @SuppressWarnings("java:S107") public Room(RoomStatus roomStatus, String title, List languages, LocalDateTime startAt, RoomAccessType roomAccessType, String problemLink, String problemPlatform, String password, Integer roomLimit, List tags,