Skip to content

Commit

Permalink
Feat : DIG-111 인바디 등록 시 routine id가 없는 경우 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dunowljj authored and Dongjin113 committed Nov 23, 2023
1 parent ad74977 commit 737b6ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/ogjg/daitgym/domain/Inbody.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 2 additions & 3 deletions src/main/java/com/ogjg/daitgym/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -219,7 +218,7 @@ private boolean isFilesListNull(List<MultipartFile> 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)
Expand All @@ -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);
}

Expand Down

0 comments on commit 737b6ae

Please sign in to comment.