From b9e6c833238f0aba27629f7af018be04dfb8da65 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 29 Oct 2024 21:24:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20enum=20=EB=B0=8F=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20canceled=EB=A1=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/domain/StudyStatus.java | 2 +- .../gdsc/domain/study/domain/vo/Assignment.java | 11 +++++------ .../gdsc/domain/study/domain/vo/Curriculum.java | 4 ++-- .../response/AssignmentSubmissionStatusResponse.java | 6 +++--- .../study/dto/response/AssignmentSubmittableDto.java | 6 +++--- .../study/dto/response/AttendanceStatusResponse.java | 6 +++--- .../study/dto/response/StudyStudentResponse.java | 8 ++++---- .../domain/study/dto/response/StudyTodoResponse.java | 6 +++--- .../gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- .../application/MentorStudyDetailServiceTest.java | 4 ++-- .../gdsc/domain/study/domain/StudyDetailTest.java | 2 +- 11 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyStatus.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyStatus.java index dc6c803a3..6b1f084f4 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyStatus.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyStatus.java @@ -8,7 +8,7 @@ public enum StudyStatus { NONE("생성"), OPEN("개설"), - CANCELLED("휴강"); + CANCELED("휴강"); private final String value; } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java index ad503826b..f92308d83 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java @@ -1,7 +1,6 @@ package com.gdschongik.gdsc.domain.study.domain.vo; import static com.gdschongik.gdsc.domain.study.domain.StudyStatus.*; -import static com.gdschongik.gdsc.domain.study.domain.StudyStatus.CANCELLED; import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import com.gdschongik.gdsc.domain.study.domain.StudyStatus; @@ -60,7 +59,7 @@ public static Assignment empty() { } public static Assignment canceled() { - return Assignment.builder().status(CANCELLED).build(); + return Assignment.builder().status(CANCELED).build(); } public void validateSubmittable(LocalDateTime now) { @@ -68,8 +67,8 @@ public void validateSubmittable(LocalDateTime now) { throw new CustomException(ASSIGNMENT_SUBMIT_NOT_PUBLISHED); } - if (status == CANCELLED) { - throw new CustomException(ASSIGNMENT_SUBMIT_CANCELLED); + if (status == CANCELED) { + throw new CustomException(ASSIGNMENT_SUBMIT_CANCELED); } if (now.isAfter(deadline)) { @@ -83,8 +82,8 @@ public boolean isOpen() { return status == OPEN; } - public boolean isCancelled() { - return status == CANCELLED; + public boolean isCanceled() { + return status == CANCELED; } public boolean isNone() { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Curriculum.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Curriculum.java index b8e592a9f..e364ea94d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Curriculum.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Curriculum.java @@ -61,7 +61,7 @@ public boolean isOpen() { return status == StudyStatus.OPEN; } - public boolean isCancelled() { - return status == StudyStatus.CANCELLED; + public boolean isCanceled() { + return status == StudyStatus.CANCELED; } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmissionStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmissionStatusResponse.java index b0d9b3935..ba8d35742 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmissionStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmissionStatusResponse.java @@ -11,13 +11,13 @@ public enum AssignmentSubmissionStatusResponse { NOT_SUBMITTED("미제출"), FAILURE("제출 실패"), SUCCESS("제출 성공"), - CANCELLED("휴강"); + CANCELED("휴강"); private final String value; public static AssignmentSubmissionStatusResponse of(AssignmentHistory assignmentHistory, StudyDetail studyDetail) { - if (studyDetail.getAssignment().isCancelled()) { - return CANCELLED; + if (studyDetail.getAssignment().isCanceled()) { + return CANCELED; } if (assignmentHistory == null) { return NOT_SUBMITTED; diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmittableDto.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmittableDto.java index 3fe71fa6b..5d84d1b7d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmittableDto.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentSubmittableDto.java @@ -24,8 +24,8 @@ public record AssignmentSubmittableDto( public static AssignmentSubmittableDto of(StudyDetail studyDetail, AssignmentHistory assignmentHistory) { Assignment assignment = studyDetail.getAssignment(); - if (assignment.isCancelled()) { - return cancelledAssignment(studyDetail, assignment); + if (assignment.isCanceled()) { + return canceledAssignment(studyDetail, assignment); } if (assignmentHistory == null) { @@ -45,7 +45,7 @@ public static AssignmentSubmittableDto of(StudyDetail studyDetail, AssignmentHis assignmentHistory.getCommittedAt()); } - private static AssignmentSubmittableDto cancelledAssignment(StudyDetail studyDetail, Assignment assignment) { + private static AssignmentSubmittableDto canceledAssignment(StudyDetail studyDetail, Assignment assignment) { return new AssignmentSubmittableDto( studyDetail.getId(), assignment.getStatus(), diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AttendanceStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AttendanceStatusResponse.java index 6fac26b65..b204117ba 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AttendanceStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AttendanceStatusResponse.java @@ -12,13 +12,13 @@ public enum AttendanceStatusResponse { ATTENDED("출석"), NOT_ATTENDED("미출석"), BEFORE_ATTENDANCE("출석전"), - CANCELLED("휴강"); + CANCELED("휴강"); private final String value; public static AttendanceStatusResponse of(StudyDetail studyDetail, LocalDate now, boolean isAttended) { - if (studyDetail.getCurriculum().isCancelled()) { - return CANCELLED; + if (studyDetail.getCurriculum().isCanceled()) { + return CANCELED; } if (studyDetail.getAttendanceDay().isAfter(now)) { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStudentResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStudentResponse.java index 35ed19f34..b197367d5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStudentResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStudentResponse.java @@ -35,10 +35,10 @@ public static StudyStudentResponse of( .toList(); long successAssignmentsCount = countAssignmentByStatus(assignments, SUCCESS); - long cancelledAssignmentsCount = countAssignmentByStatus(assignments, CANCELLED); + long canceledAssignmentsCount = countAssignmentByStatus(assignments, CANCELED); long attendedCount = countAttendanceByStatus(attendances, AttendanceStatusResponse.ATTENDED); - long cancelledAttendanceCount = countAttendanceByStatus(attendances, AttendanceStatusResponse.CANCELLED); + long canceledAttendanceCount = countAttendanceByStatus(attendances, AttendanceStatusResponse.CANCELED); return new StudyStudentResponse( studyHistory.getStudent().getId(), @@ -51,8 +51,8 @@ public static StudyStudentResponse of( isOutstandingStudent(FIRST_ROUND_OUTSTANDING_STUDENT, studyAchievements), isOutstandingStudent(SECOND_ROUND_OUTSTANDING_STUDENT, studyAchievements), studyTodos, - calculateRateOrZero(successAssignmentsCount, assignments.size() - cancelledAssignmentsCount), - calculateRateOrZero(attendedCount, attendances.size() - cancelledAttendanceCount)); + calculateRateOrZero(successAssignmentsCount, assignments.size() - canceledAssignmentsCount), + calculateRateOrZero(attendedCount, attendances.size() - canceledAttendanceCount)); } private static boolean isOutstandingStudent( diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyTodoResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyTodoResponse.java index 518fd512b..ddd013c6f 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyTodoResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyTodoResponse.java @@ -22,13 +22,13 @@ public record StudyTodoResponse( @Schema(description = "과제 제출 상태 (과제타입일 때만 사용)") AssignmentSubmissionStatusResponse assignmentSubmissionStatus) { public static StudyTodoResponse createAttendanceType(StudyDetail studyDetail, LocalDate now, boolean isAttended) { - if (studyDetail.getCurriculum().isCancelled()) { + if (studyDetail.getCurriculum().isCanceled()) { return new StudyTodoResponse( studyDetail.getId(), studyDetail.getWeek(), ATTENDANCE, null, - AttendanceStatusResponse.CANCELLED, + AttendanceStatusResponse.CANCELED, null, null); } @@ -43,7 +43,7 @@ public static StudyTodoResponse createAttendanceType(StudyDetail studyDetail, Lo } public static StudyTodoResponse createAssignmentType(StudyDetail studyDetail, AssignmentHistory assignmentHistory) { - if (studyDetail.getAssignment().isCancelled()) { + if (studyDetail.getAssignment().isCanceled()) { return new StudyTodoResponse( studyDetail.getId(), studyDetail.getWeek(), diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 4ab02f3f8..36d1984c4 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -162,7 +162,7 @@ public enum ErrorCode { ASSIGNMENT_STUDY_NOT_APPLIED(HttpStatus.CONFLICT, "해당 스터디에 대한 수강신청 기록이 존재하지 않습니다."), ASSIGNMENT_SUBMIT_NOT_STARTED(HttpStatus.CONFLICT, "아직 과제가 시작되지 않았습니다."), ASSIGNMENT_SUBMIT_NOT_PUBLISHED(HttpStatus.CONFLICT, "아직 과제가 등록되지 않았습니다."), - ASSIGNMENT_SUBMIT_CANCELLED(HttpStatus.CONFLICT, "과제 휴강 주간에는 과제를 제출할 수 없습니다."), + ASSIGNMENT_SUBMIT_CANCELED(HttpStatus.CONFLICT, "과제 휴강 주간에는 과제를 제출할 수 없습니다."), ASSIGNMENT_SUBMIT_DEADLINE_PASSED(HttpStatus.CONFLICT, "과제 마감 기한이 지났습니다."), // Github diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailServiceTest.java index 190b508c6..f44f5caaa 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailServiceTest.java @@ -40,9 +40,9 @@ class 스터디_과제_휴강_처리시 { mentorStudyDetailService.cancelStudyAssignment(studyDetail.getId()); // then - StudyDetail cancelledStudyDetail = + StudyDetail canceledStudyDetail = studyDetailRepository.findById(studyDetail.getId()).get(); - assertThat(cancelledStudyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELLED); + assertThat(canceledStudyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELED); } } } diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyDetailTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyDetailTest.java index a0519795b..ea11632e1 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyDetailTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyDetailTest.java @@ -29,7 +29,7 @@ class 과제_휴강_처리시 { studyDetail.cancelAssignment(); // then - assertThat(studyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELLED); + assertThat(studyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELED); } }