diff --git a/module-api/src/main/java/com/kernel360/member/dto/MemberInfo.java b/module-api/src/main/java/com/kernel360/member/dto/MemberInfo.java index 8170602f..c82bc74e 100644 --- a/module-api/src/main/java/com/kernel360/member/dto/MemberInfo.java +++ b/module-api/src/main/java/com/kernel360/member/dto/MemberInfo.java @@ -1,10 +1,8 @@ package com.kernel360.member.dto; - - public record MemberInfo( - int gender, - int age + int gender, + int age ) { } \ No newline at end of file diff --git a/module-api/src/main/java/com/kernel360/member/service/MemberService.java b/module-api/src/main/java/com/kernel360/member/service/MemberService.java index c7b7e7b3..167ca717 100644 --- a/module-api/src/main/java/com/kernel360/member/service/MemberService.java +++ b/module-api/src/main/java/com/kernel360/member/service/MemberService.java @@ -173,14 +173,17 @@ public Map getCarInfo(String token) { } @Transactional(readOnly = true) - public Optional getWashInfo(String token) { + public WashInfoDto getWashInfo(String token) { String id = JWT.ownerId(token); Member member = memberRepository.findOneById(id); if (member == null) { throw new BusinessException(MemberErrorCode.FAILED_FIND_MEMBER_INFO); } - - return Optional.of(WashInfoDto.from(member.getWashInfo())); + WashInfo washInfo = member.getWashInfo(); + if(washInfo == null){ + throw new BusinessException(MemberErrorCode.FAILED_FIND_MEMBER_WASH_INFO); + } + return WashInfoDto.from(washInfo); } @Transactional diff --git a/module-api/src/main/java/com/kernel360/mypage/controller/MyPageController.java b/module-api/src/main/java/com/kernel360/mypage/controller/MyPageController.java index ec35ab86..e848d759 100644 --- a/module-api/src/main/java/com/kernel360/mypage/controller/MyPageController.java +++ b/module-api/src/main/java/com/kernel360/mypage/controller/MyPageController.java @@ -41,8 +41,7 @@ ResponseEntity>> myCar(@RequestHeader("Authoriza @GetMapping("/wash") ResponseEntity> myWash(@RequestHeader("Authorization") String authToken) { - WashInfoDto washInfoDto = memberService.getWashInfo(authToken) - .orElseThrow(() -> new BusinessException(MemberErrorCode.FAILED_FIND_MEMBER_WASH_INFO)); + WashInfoDto washInfoDto = memberService.getWashInfo(authToken); return ApiResponse.toResponseEntity(MemberBusinessCode.SUCCESS_FIND_WASH_INFO_IN_MEMBER, washInfoDto); }