|
1 | 1 | package com.tnt.application.pt;
|
2 | 2 |
|
3 |
| -import static com.tnt.common.error.model.ErrorMessage.PT_LESSON_DUPLICATE_TIME; |
4 |
| -import static com.tnt.common.error.model.ErrorMessage.PT_LESSON_NOT_FOUND; |
5 |
| -import static com.tnt.common.error.model.ErrorMessage.PT_TRAINEE_ALREADY_EXIST; |
6 |
| -import static com.tnt.common.error.model.ErrorMessage.PT_TRAINER_TRAINEE_ALREADY_EXIST; |
7 |
| -import static com.tnt.common.error.model.ErrorMessage.PT_TRAINER_TRAINEE_NOT_FOUND; |
| 3 | +import static com.tnt.common.error.model.ErrorMessage.*; |
8 | 4 |
|
9 | 5 | import java.time.LocalDate;
|
10 | 6 | import java.time.LocalDateTime;
|
|
33 | 29 | import com.tnt.dto.trainer.response.ConnectWithTraineeResponse.ConnectTraineeInfo;
|
34 | 30 | import com.tnt.dto.trainer.response.ConnectWithTraineeResponse.ConnectTrainerInfo;
|
35 | 31 | import com.tnt.dto.trainer.response.GetActiveTraineesResponse;
|
36 |
| -import com.tnt.dto.trainer.response.GetActiveTraineesResponse.TraineeDto; |
| 32 | +import com.tnt.dto.trainer.response.GetActiveTraineesResponse.TraineeInfo; |
37 | 33 | import com.tnt.dto.trainer.response.GetCalendarPtLessonCountResponse;
|
38 | 34 | import com.tnt.dto.trainer.response.GetCalendarPtLessonCountResponse.CalendarPtLessonCount;
|
39 | 35 | import com.tnt.dto.trainer.response.GetPtLessonsOnDateResponse;
|
@@ -145,11 +141,23 @@ public GetActiveTraineesResponse getActiveTrainees(Long memberId) {
|
145 | 141 | Trainer trainer = trainerService.getTrainerWithMemberId(memberId);
|
146 | 142 |
|
147 | 143 | List<Trainee> trainees = ptTrainerTraineeSearchRepository.findAllTrainees(trainer.getId());
|
148 |
| - List<TraineeDto> traineeDto = trainees.stream() |
149 |
| - .map(trainee -> new TraineeDto(trainee.getId(), trainee.getMember().getName())) |
150 |
| - .toList(); |
151 | 144 |
|
152 |
| - return new GetActiveTraineesResponse(traineeDto); |
| 145 | + List<TraineeInfo> traineeInfo = trainees.stream().map(trainee -> { |
| 146 | + PtTrainerTrainee ptTrainerTrainee = ptTrainerTraineeRepository.findByTraineeIdAndDeletedAtIsNull( |
| 147 | + trainee.getId()) |
| 148 | + .orElseThrow(() -> new NotFoundException(TRAINEE_NOT_FOUND)); |
| 149 | + |
| 150 | + List<String> ptGoals = ptGoalService.getAllPtGoalsWithTraineeId(trainee.getId()) |
| 151 | + .stream() |
| 152 | + .map(PtGoal::getContent) |
| 153 | + .toList(); |
| 154 | + |
| 155 | + return new TraineeInfo(trainee.getId(), trainee.getMember().getName(), |
| 156 | + ptTrainerTrainee.getFinishedPtCount(), ptTrainerTrainee.getTotalPtCount(), trainee.getCautionNote(), |
| 157 | + ptGoals); |
| 158 | + }).toList(); |
| 159 | + |
| 160 | + return new GetActiveTraineesResponse(trainees.size(), traineeInfo); |
153 | 161 | }
|
154 | 162 |
|
155 | 163 | @Transactional
|
|
0 commit comments