diff --git a/src/main/java/com/danpoong/onchung/domain/policy/controller/PolicyController.java b/src/main/java/com/danpoong/onchung/domain/policy/controller/PolicyController.java index 5f1bf24..2a81830 100644 --- a/src/main/java/com/danpoong/onchung/domain/policy/controller/PolicyController.java +++ b/src/main/java/com/danpoong/onchung/domain/policy/controller/PolicyController.java @@ -1,6 +1,5 @@ package com.danpoong.onchung.domain.policy.controller; -import com.danpoong.onchung.domain.policy.domain.enums.PolicyPath; import com.danpoong.onchung.domain.policy.dto.PolicyPathRequestDto; import com.danpoong.onchung.domain.policy.dto.PolicyPathResponseDto; import com.danpoong.onchung.domain.policy.dto.PolicyResponseDto; @@ -40,7 +39,7 @@ public ResponseTemplate makePolicyPath( @Operation(summary = "발급 받은 복지패스 조회") @GetMapping("/path") - public ResponseTemplate> getPolicyPath(@AuthenticationPrincipal Long userId) { + public ResponseTemplate> getPolicyPath(@AuthenticationPrincipal Long userId) { return new ResponseTemplate<>(HttpStatus.OK, "발급한 복지패스 조회 성공", policyService.getPolicyPaths(userId)); } diff --git a/src/main/java/com/danpoong/onchung/domain/policy/service/PolicyService.java b/src/main/java/com/danpoong/onchung/domain/policy/service/PolicyService.java index e6875f2..c1671c2 100644 --- a/src/main/java/com/danpoong/onchung/domain/policy/service/PolicyService.java +++ b/src/main/java/com/danpoong/onchung/domain/policy/service/PolicyService.java @@ -62,16 +62,19 @@ public PolicyPathResponseDto makePolicyPath(Long userId, PolicyPathRequestDto re PolicyPath tempPolicyPath = determinePolicyPath(requestDto); - userInfo.addPolicyPath(tempPolicyPath); + if (!userInfo.getPolicyPaths().contains(tempPolicyPath)) { + userInfo.addPolicyPath(tempPolicyPath); + } return PolicyPathResponseDto.builder() .policyPathNum(tempPolicyPath.getNumber()) .build(); } - public List getPolicyPaths(Long userId) { + public List getPolicyPaths(Long userId) { UserInfo userInfo = userInfoRepository.findById(userId).orElseThrow(() -> new UserNotFoundException("해당 ID의 유저 정보를 찾을 수 없습니다.")); - return userInfo.getPolicyPaths(); + + return userInfo.getPolicyPaths().stream().map(PolicyPath::getNumber).toList(); } private PolicyPath determinePolicyPath(PolicyPathRequestDto requestDto) {