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 @@ -4,5 +4,5 @@
import reactor.core.publisher.Mono;

public interface AuthClient {
public Mono<UserCacheDto> validateToken(String token);
Mono<UserCacheDto> validateToken(String token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
switch (api) {
case ENTER_WAITING_QUEUE -> handleEnterWaitingQueueApi(exchange, chain);
case GET_QUEUE_INFO -> handleGetQueueInfoApi(exchange, chain);
case PRE_RESERVE_SEAT, CREATE_ORDER, VALIDATE_ORDER -> handleCreateOrderApi(exchange, chain);
case PRE_RESERVE_SEAT, CREATE_ORDER, VALIDATE_ORDER -> handleReservationApi(exchange, chain);
})
.switchIfEmpty(chain.filter(exchange));
}
Expand All @@ -53,7 +53,7 @@ private Mono<Void> handleGetQueueInfoApi(ServerWebExchange exchange, GatewayFilt
.then(chain.filter(exchange));
}

private Mono<Void> handleCreateOrderApi(ServerWebExchange exchange, GatewayFilterChain chain) {
private Mono<Void> handleReservationApi(ServerWebExchange exchange, GatewayFilterChain chain) {
return Mono.zip(
getPerformanceIdFromQueryParams(exchange),
getUserIdFromAuthentication()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class RedisCacheService implements CacheService {

public void saveRefreshToken(UUID userId, String refreshToken) {
String key = generateKey(userId);
System.out.println(REFRESH_TOKEN_EXPIRATION);
redisRepository.setValueWithTTL(key, refreshToken, Duration.ofMillis(REFRESH_TOKEN_EXPIRATION));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ public PaymentResponse getCompletedPaymentByOrderId(UUID orderId) {
Payment payment = paymentDomainService.getCompletedPaymentByOrderId(orderId);
return PaymentResponse.from(payment);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ public Payment getCompletedPaymentByOrderId(UUID orderId) {
return paymentRepository.findByOrderIdAndStatus(orderId, PaymentStatus.COMPLETED)
.orElseThrow(() -> new ApplicationException(PAYMENT_NOT_FOUND));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public ResponseEntity<CommonResponse<JSONObject>> confirmPayment(@Valid @Request

@Operation(summary = "결제 단일 조회 (Feign)")
@GetMapping("/{paymentId}")
public ResponseEntity<CommonResponse<PaymentResponse>> getPayment(
public ResponseEntity<CommonResponse<PaymentResponse>> getPaymentInfo(
@Valid @PathVariable("paymentId") UUID paymentId) {
return ResponseEntity
.status(200)
.body(success(paymentApplicationService.getPayment(paymentId)));
}

@Operation(summary = "성공 예매 확인")
@Operation(summary = "결제 성공 확인 (Feign)")
@GetMapping("/completed")
public ResponseEntity<CommonResponse<PaymentResponse>> getCompletedPaymentByOrderId(
@Valid @RequestParam("orderId") UUID orderId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.ticketPing.performance.domain.model.enums.SeatStatus;
import com.ticketPing.performance.domain.repository.CacheRepository;
import com.ticketPing.performance.domain.repository.SeatRepository;
import com.ticketPing.performance.infrastructure.service.LuaScriptService;
import exception.ApplicationException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -81,15 +80,14 @@ private Seat getSeatWithDetails(UUID seatId) {
.orElseThrow(() -> new ApplicationException(SeatExceptionCase.SEAT_NOT_FOUND));
}

@Transactional
private void reserveSeatInDB(String seatId) {
Seat seat = seatRepository.findById(UUID.fromString(seatId))
.orElseThrow(() -> new ApplicationException(SeatExceptionCase.SEAT_NOT_FOUND));
seat.reserveSeat();
}

private void validatePreserve(UUID scheduleId, UUID seatId, UUID userId) {
String preReserveUserId = cacheRepository.getPreReservTTL(scheduleId, seatId);
String preReserveUserId = cacheRepository.getPreReserveUserId(scheduleId, seatId);
if(!preReserveUserId.equals(userId.toString()))
throw new ApplicationException(SeatExceptionCase.USER_NOT_MATCH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface CacheRepository {

void preReserveSeatCache(UUID scheduleId, UUID seatId, UUID userId);

String getPreReservTTL(UUID scheduleId, UUID seatId);
String getPreReserveUserId(UUID scheduleId, UUID seatId);

void extendPreReserveTTL(UUID scheduleId, UUID seatId, Duration ttl);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
package com.ticketPing.performance.domain.repository;

import com.ticketPing.performance.domain.model.entity.Schedule;

import java.util.Optional;
import java.util.UUID;

public interface ScheduleRepository {
Optional<Schedule> findById(UUID id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void preReserveSeatCache(UUID scheduleId, UUID seatId, UUID userId) {
luaScriptService.preReserveSeat(scheduleId, seatId, userId);
}

public String getPreReservTTL(UUID scheduleId, UUID seatId) {
public String getPreReserveUserId(UUID scheduleId, UUID seatId) {
String ttlKey = PRE_RESERVE_SEAT_KEY + ":{" + scheduleId + "}:" + seatId;
RBucket<String> bucket = redissonClient.getBucket(ttlKey);
return Optional.ofNullable(bucket.get())
Expand Down
Loading