Skip to content

Commit

Permalink
Merge pull request #227 from cgk95/hotfix/wash_exception_handling
Browse files Browse the repository at this point in the history
Hotfix :: 세차 정보 예외 핸들링 추가
  • Loading branch information
chan99k committed Feb 29, 2024
2 parents 0ec3b72 + 232e911 commit 51239ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.kernel360.member.dto;




public record MemberInfo(
int gender,
int age
int gender,
int age
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ public Map<String, Object> getCarInfo(String token) {
}

@Transactional(readOnly = true)
public Optional<WashInfoDto> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ ResponseEntity<ApiResponse<Map<String, Object>>> myCar(@RequestHeader("Authoriza

@GetMapping("/wash")
ResponseEntity<ApiResponse<WashInfoDto>> 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);
}
Expand Down

0 comments on commit 51239ee

Please sign in to comment.