Skip to content

Commit cd39329

Browse files
committed
hotfix: 수업 완료 버그 수정
1 parent 2b31d7f commit cd39329

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

src/main/java/com/tnt/pt/application/PtService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void completePtLesson(Long memberId, Long ptLessonId) {
205205
ptLesson.complete(ptTrainerTrainee.getFinishedPtCount());
206206

207207
List<PtLesson> lessonsNotCompleted =
208-
ptLessonRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalse(ptTrainerTrainee);
208+
ptLessonRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalseWithout(ptTrainerTrainee, ptLessonId);
209209

210210
lessonsNotCompleted.forEach(lesson -> {
211211
if (!lesson.getId().equals(ptLessonId)) {
@@ -226,7 +226,7 @@ public void cancelPtLesson(Long memberId, Long ptLessonId) {
226226
PtTrainerTrainee ptTrainerTrainee = ptLesson.getPtTrainerTrainee();
227227

228228
List<PtLesson> lessonsNotCompleted =
229-
ptLessonRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalse(ptTrainerTrainee);
229+
ptLessonRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalseWithout(ptTrainerTrainee, ptLessonId);
230230

231231
lessonsNotCompleted.forEach(lesson -> {
232232
if (!lesson.getId().equals(ptLessonId) && lesson.getSession() > ptLesson.getSession()) {

src/main/java/com/tnt/pt/application/repository/PtLessonRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface PtLessonRepository {
1919

2020
List<PtLesson> findAllByPtTrainerTrainee(PtTrainerTrainee ptTrainerTrainee);
2121

22-
List<PtLesson> findAllByPtTrainerTraineeAndIsCompletedIsFalse(PtTrainerTrainee ptTrainerTrainee);
22+
List<PtLesson> findAllByPtTrainerTraineeAndIsCompletedIsFalseWithout(PtTrainerTrainee ptTrainerTrainee, Long id);
2323

2424
List<PtLesson> findAllByTrainerIdAndDate(Long trainerId, LocalDate date);
2525

src/main/java/com/tnt/pt/infrastructure/PtLessonJpaRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public interface PtLessonJpaRepository extends JpaRepository<PtLessonJpaEntity,
99
List<PtLessonJpaEntity> findAllByPtTrainerTraineeAndDeletedAtIsNull(
1010
PtTrainerTraineeJpaEntity ptTrainerTraineeJpaEntity);
1111

12-
List<PtLessonJpaEntity> findAllByPtTrainerTraineeAndIsCompletedIsFalseAndDeletedAtIsNull(
13-
PtTrainerTraineeJpaEntity ptTrainerTraineeJpaEntity);
12+
List<PtLessonJpaEntity> findAllByPtTrainerTraineeAndIsCompletedIsFalseAndIdIsNotAndDeletedAtIsNull(
13+
PtTrainerTraineeJpaEntity ptTrainerTraineeJpaEntity, Long id);
1414
}

src/main/java/com/tnt/pt/infrastructure/PtLessonRepositoryImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ public List<PtLesson> findAllByPtTrainerTrainee(PtTrainerTrainee ptTrainerTraine
6363
}
6464

6565
@Override
66-
public List<PtLesson> findAllByPtTrainerTraineeAndIsCompletedIsFalse(PtTrainerTrainee ptTrainerTrainee) {
67-
return ptLessonJpaRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalseAndDeletedAtIsNull(
68-
PtTrainerTraineeJpaEntity.from(ptTrainerTrainee))
66+
public List<PtLesson> findAllByPtTrainerTraineeAndIsCompletedIsFalseWithout(PtTrainerTrainee ptTrainerTrainee,
67+
Long id) {
68+
return ptLessonJpaRepository.findAllByPtTrainerTraineeAndIsCompletedIsFalseAndIdIsNotAndDeletedAtIsNull(
69+
PtTrainerTraineeJpaEntity.from(ptTrainerTrainee), id)
6970
.stream()
7071
.map(PtLessonJpaEntity::toModel)
7172
.toList();

src/test/java/com/tnt/trainer/presentation/TrainerControllerTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,10 @@ void complete_pt_lesson_success() throws Exception {
10901090
// when & then
10911091
mockMvc.perform(put("/trainers/lessons/{ptLessonId}/complete", ptLesson1.getId()))
10921092
.andExpect(status().isOk());
1093+
1094+
PtLesson result = ptLessonRepository.findById(ptLesson1.getId());
1095+
1096+
assertThat(result.getIsCompleted()).isTrue();
10931097
}
10941098

10951099
@Test

0 commit comments

Comments
 (0)