Skip to content

Commit

Permalink
refactor: enum 및 변수명 canceled로 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Oct 29, 2024
1 parent 014cf8c commit b9e6c83
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public enum StudyStatus {
NONE("생성"),
OPEN("개설"),
CANCELLED("휴강");
CANCELED("휴강");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -60,16 +59,16 @@ 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) {
if (status == NONE) {
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)) {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class 과제_휴강_처리시 {
studyDetail.cancelAssignment();

// then
assertThat(studyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELLED);
assertThat(studyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELED);
}
}

Expand Down

0 comments on commit b9e6c83

Please sign in to comment.