diff --git a/src/main/java/com/ogjg/daitgym/domain/Inbody.java b/src/main/java/com/ogjg/daitgym/domain/Inbody.java index c7939dae..11c3ba87 100644 --- a/src/main/java/com/ogjg/daitgym/domain/Inbody.java +++ b/src/main/java/com/ogjg/daitgym/domain/Inbody.java @@ -52,4 +52,8 @@ public Inbody(Long id, User user, int score, double skeletalMuscleMass, double b this.measureAt = measureAt; this.routine = routine; } + + public void addRoutineId(Routine routine) { + this.routine = routine; + } } diff --git a/src/main/java/com/ogjg/daitgym/user/service/UserService.java b/src/main/java/com/ogjg/daitgym/user/service/UserService.java index f754fb28..588104c8 100644 --- a/src/main/java/com/ogjg/daitgym/user/service/UserService.java +++ b/src/main/java/com/ogjg/daitgym/user/service/UserService.java @@ -4,7 +4,6 @@ import com.ogjg.daitgym.approval.repository.AwardRepository; import com.ogjg.daitgym.approval.repository.CertificationRepository; import com.ogjg.daitgym.comment.feedExerciseJournal.exception.WrongApproach; -import com.ogjg.daitgym.comment.routine.exception.NotFoundRoutine; import com.ogjg.daitgym.common.exception.user.AlreadyExistNickname; import com.ogjg.daitgym.common.exception.user.AlreadyProceedingApproval; import com.ogjg.daitgym.common.exception.user.EmptyTrainerApplyException; @@ -219,7 +218,7 @@ private boolean isFilesListNull(List imgFiles) { public void registerInbody(String loginEmail, RegisterInbodyRequest request) { User user = userHelper.findUserByEmail(loginEmail); Routine routine = routineRepository.findById(request.getRoutineId()) - .orElseThrow(NotFoundRoutine::new); + .orElse(null); Inbody inbody = Inbody.builder() .user(user) @@ -229,9 +228,9 @@ public void registerInbody(String loginEmail, RegisterInbodyRequest request) { .bodyFatRatio(request.getBodyFatRatio()) .weight(request.getWeight()) .basalMetabolicRate(request.getBasalMetabolicRate()) - .routine(routine) .build(); + if (routine != null) inbody.addRoutineId(routine); inbodyRepository.save(inbody); }