Skip to content

Commit

Permalink
Merge pull request #244 from sopt-makers/sohyeon_#243
Browse files Browse the repository at this point in the history
[FIX] �테스트 중 500 에러 수정
  • Loading branch information
thguss authored Feb 18, 2024
2 parents 8318ebb + 8ea47c1 commit 535d2eb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ResponseEntity<BaseResponse<?>> startSubLecture(SubLectureStartRequest re
@PatchMapping("/{lectureId}")
public ResponseEntity<BaseResponse<?>> endLecture(@PathVariable long lectureId) {
lectureService.endLecture(lectureId);
return ApiResponseUtil.success(SUCCESS_UPDATE_MEMBER_SCORE);
return ApiResponseUtil.success(SUCCESS_END_LECTURE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ private SubLecture getSubLectureToStartAttendance(Lecture lecture, int round) {

private Lecture getLectureReadyToEnd(long lectureId) {
val lecture = findLecture(lectureId);
if (!lecture.isEnd()) {
if (lecture.isNotYetToEnd()) {
throw new LectureException(NOT_END_TIME_YET);
}
if (lecture.isEnd()) {
throw new LectureException(END_LECTURE);
}
return lecture;
}

Expand All @@ -190,7 +193,7 @@ private void restoreAttendances(List<Attendance> attendances) {
private void deleteRelationship(Lecture lecture) {
subAttendanceRepository.deleteAllBySubLectureIn(lecture.getSubLectures());
subLectureRepository.deleteAllByLecture(lecture);
attendanceRepository.deleteAllByLecture(lecture);
attendanceRepository.deleteByLecture(lecture);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum LectureSuccessCode implements SuccessCode {
SUCCESS_GET_MEMBERS(OK, "유저 리스트 조회 성공"),
SUCCESS_DELETE_LECTURE(OK, "세션 삭제 성공"),
SUCCESS_UPDATE_MEMBER_SCORE(OK, "회원 출석 점수 갱신 성공"),
SUCCESS_END_LECTURE(OK, "세션 종료 성공"),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@

public interface AttendanceRepository extends JpaRepository<Attendance, Long>, AttendanceCustomRepository {
Optional<Attendance> findByLectureAndMember(Lecture lecture, Member member);
@Query("delete from Attendance a where a.lecture = :lecture")
void deleteAllByLecture(Lecture lecture);
void deleteByLecture(Lecture lecture);
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@ public boolean isBefore() {
public boolean isFirst() {
return this.lectureStatus.equals(FIRST);
}

public boolean isNotYetToEnd() {
return this.endDate.isAfter(LocalDateTime.now());
}
}

0 comments on commit 535d2eb

Please sign in to comment.