From a19ee50e9578f7c5c1554b98341f40d83d45ecfb Mon Sep 17 00:00:00 2001 From: cgk95 Date: Thu, 29 Feb 2024 17:10:42 +0900 Subject: [PATCH] =?UTF-8?q?feat=20::=20=EC=84=B8=EC=B0=A8=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EA=B0=80=20=EC=97=86=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?400=20=EB=A9=94=EC=8B=9C=EC=A7=80=EB=A5=BC=20=ED=95=B8=EB=93=A4?= =?UTF-8?q?=EB=A7=81=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/kernel360/member/dto/MemberInfo.java | 6 ++---- .../java/com/kernel360/member/service/MemberService.java | 9 ++++++--- .../kernel360/mypage/controller/MyPageController.java | 3 +-- 3 files changed, 9 insertions(+), 9 deletions(-) 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); }