Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorePaymentReadDto> response = storePaymentService.getStorePaymentByStoreId(storeId);
public ResponseEntity<?> getStorePaymentByStoreId(@PathVariable String publicCode) {
Optional<StorePaymentReadDto> response = storePaymentService.getStorePaymentByStoreId(publicCode);

if (response.isPresent()) {
return ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import com.nowait.applicationuser.storepayment.dto.StorePaymentReadDto;

public interface StorePaymentService {
Optional<StorePaymentReadDto> getStorePaymentByStoreId(Long storeId);
Optional<StorePaymentReadDto> getStorePaymentByStoreId(String publicCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,13 +18,15 @@
public class StorePaymentServiceImpl implements StorePaymentService {

private final StorePaymentRepository storePaymentRepository;
private final StoreRepository storeRepository;

@Override
@Transactional(readOnly = true)
public Optional<StorePaymentReadDto> getStorePaymentByStoreId(Long storeId) {
if (storeId == null) throw new StorePaymentParamEmptyException();

return storePaymentRepository.findByStoreId(storeId)
public Optional<StorePaymentReadDto> 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);
}
}