diff --git a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/controller/StorePaymentController.java b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/controller/StorePaymentController.java index 12901d64..c8cd09c4 100644 --- a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/controller/StorePaymentController.java +++ b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/controller/StorePaymentController.java @@ -28,11 +28,11 @@ public class StorePaymentController { private final StorePaymentService storePaymentService; - @GetMapping(("/{storeId}")) + @GetMapping(("/{publicCode}")) @Operation(summary = "주점 결제 정보 조회", description = "주점 ID로 주점 결제 정보를 조회합니다.") @ApiResponse(responseCode = "200", description = "주점 결제 정보 조회 성공") - public ResponseEntity getStorePaymentByStoreId(@PathVariable Long storeId) { - Optional response = storePaymentService.getStorePaymentByStoreId(storeId); + public ResponseEntity getStorePaymentByStoreId(@PathVariable String publicCode) { + Optional response = storePaymentService.getStorePaymentByStoreId(publicCode); if (response.isPresent()) { return ResponseEntity diff --git a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentService.java b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentService.java index 703b8df7..100b6dac 100644 --- a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentService.java +++ b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentService.java @@ -5,5 +5,5 @@ import com.nowait.applicationuser.storepayment.dto.StorePaymentReadDto; public interface StorePaymentService { - Optional getStorePaymentByStoreId(Long storeId); + Optional getStorePaymentByStoreId(String publicCode); } diff --git a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentServiceImpl.java b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentServiceImpl.java index 5e15b7ff..c4c9c295 100644 --- a/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentServiceImpl.java +++ b/nowait-app-user-api/src/main/java/com/nowait/applicationuser/storepayment/service/StorePaymentServiceImpl.java @@ -5,6 +5,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nowait.applicationuser.storepayment.dto.StorePaymentReadDto; +import com.nowait.domaincorerdb.store.entity.Store; +import com.nowait.domaincorerdb.store.exception.StoreNotFoundException; +import com.nowait.domaincorerdb.store.repository.StoreRepository; import com.nowait.domaincorerdb.storepayment.exception.StorePaymentParamEmptyException; import com.nowait.domaincorerdb.storepayment.repository.StorePaymentRepository; @@ -15,13 +18,15 @@ public class StorePaymentServiceImpl implements StorePaymentService { private final StorePaymentRepository storePaymentRepository; + private final StoreRepository storeRepository; @Override @Transactional(readOnly = true) - public Optional getStorePaymentByStoreId(Long storeId) { - if (storeId == null) throw new StorePaymentParamEmptyException(); - - return storePaymentRepository.findByStoreId(storeId) + public Optional getStorePaymentByStoreId(String publicCode) { + if (publicCode == null) throw new StorePaymentParamEmptyException(); + Store store = storeRepository.findByPublicCodeAndDeletedFalse(publicCode) + .orElseThrow(StoreNotFoundException::new); + return storePaymentRepository.findByStoreId(store.getStoreId()) .map(StorePaymentReadDto::fromEntity); } }