Skip to content

Commit

Permalink
refactor : 회원가입시, 체중 중복 저장 핸들링
Browse files Browse the repository at this point in the history
  • Loading branch information
13wjdgk committed Oct 14, 2023
1 parent 53f955a commit d9a3ac9
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.coniverse.dangjang.domain.auth.dto.response.LoginResponse;
import com.coniverse.dangjang.domain.auth.mapper.AuthMapper;
import com.coniverse.dangjang.domain.auth.service.OauthLoginService;
import com.coniverse.dangjang.domain.guide.common.exception.GuideNotFoundException;
import com.coniverse.dangjang.domain.guide.weight.service.WeightGuideSearchService;
import com.coniverse.dangjang.domain.healthmetric.dto.request.HealthMetricPostRequest;
import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricRegisterService;
import com.coniverse.dangjang.domain.infrastructure.auth.dto.OAuthInfoResponse;
Expand Down Expand Up @@ -44,6 +46,7 @@ public class UserSignupService {
private final UserMapper userMapper;
private final AuthMapper authMapper;
private final NotificationService notificationService;
private final WeightGuideSearchService weightGuideSearchService;

/**
* 회원가입
Expand Down Expand Up @@ -120,12 +123,16 @@ private int calculateRecommendedCalorie(Gender gender, int height, ActivityAmoun
*/

private void registerWeight(User user, int weight) {
HealthMetricPostRequest healthMetricPostRequest = HealthMetricPostRequest.builder()
.type("체중")
.createdAt(user.getCreatedAt().toLocalDate().toString())
.unit(String.valueOf(weight))
.build();
healthMetricRegisterService.register(healthMetricPostRequest, user.getOauthId());
try {
weightGuideSearchService.findByUserIdAndCreatedAt(user.getOauthId(), user.getCreatedAt().toLocalDate().toString());
} catch (GuideNotFoundException e) {
HealthMetricPostRequest healthMetricPostRequest = HealthMetricPostRequest.builder()
.type("체중")
.createdAt(user.getCreatedAt().toLocalDate().toString())
.unit(String.valueOf(weight))
.build();
healthMetricRegisterService.register(healthMetricPostRequest, user.getOauthId());
}
}

/**
Expand Down

0 comments on commit d9a3ac9

Please sign in to comment.