Skip to content

Commit

Permalink
docs: 예매 http 작성 (#161)
Browse files Browse the repository at this point in the history
* docs: http 유저 시나리오 작성

* fix: createBooking에서 세션 아이디 삭제하는 로직 비동기 메서드로 분리

* docs: http 작성
  • Loading branch information
annahxxl authored Jan 8, 2024
1 parent 900bfd7 commit d7b9fc5
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,33 @@ Booking-Session-Id: {세션아이디}
"eventId": 1
}

### [Optional] 대기열 이탈
POST http://localhost:8082/api/v1/bookings/exit-queue
Content-Type: application/json
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ
Booking-Session-Id: {세션아이디}

{
"eventId": 1
}

### 좌석 목록 조회
GET http://localhost:8082/api/v1/seats?eventTimeId=1
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ
Booking-Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NjkzNDQ4LCJleHAiOjE3MDQ2OTUyNDgsInNlc3Npb25JZCI6Ins_Pz8_P30ifQ.IFqm66RBlLw6ZVbogZdTvClpH2arxAfWTZ1-DNFtT-H7EH0OSYUoICgnpMjbI2aSObsdl1h3oVSQPw28XlmJzg
Booking-Authorization: Bearer eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NzA0NTY0LCJleHAiOjQyMDAxNzA0NzA0NTY0LCJzZXNzaW9uSWQiOiJ7Pz8_Pz99In0.iKZaud5vfvsMzXmQzl1WaCweL9GL00U0iGzCg4_p3Zzei8Y7z19Ff_TTpxh9gLeB

### 예매
POST http://localhost:8082/api/v1/bookings
Content-Type: application/json
### 예매 ~ 결제 (브라우저에서 진행해 주세요)
GET http://localhost:8082/bookings

### [Optional] 예매 이탈
POST http://localhost:8082/api/v1/bookings/bookingCreateTestId/exit
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ
Booking-Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NjkzNDQ4LCJleHAiOjE3MDQ2OTUyNDgsInNlc3Npb25JZCI6Ins_Pz8_P30ifQ.IFqm66RBlLw6ZVbogZdTvClpH2arxAfWTZ1-DNFtT-H7EH0OSYUoICgnpMjbI2aSObsdl1h3oVSQPw28XlmJzg
Booking-Authorization: Bearer eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NzA0NTY0LCJleHAiOjQyMDAxNzA0NzA0NTY0LCJzZXNzaW9uSWQiOiJ7Pz8_Pz99In0.iKZaud5vfvsMzXmQzl1WaCweL9GL00U0iGzCg4_p3Zzei8Y7z19Ff_TTpxh9gLeB

### 예매 취소 (브라우저에서 생성된 예매번호로 진행해 주세요)
POST http://localhost:8082/api/v1/bookings/1704704631741/cancel
Content-Type: application/json

{
"timeId": 1,
"seatIds": [3, 4],
"receiptType": "배송",
"buyerName": "이한나",
"buyerPhoneNumber": "010-1234-5678",
"deliveryAddress": {
"recipientName": "이한나",
"recipientPhoneNumber": "010-1234-5678",
"streetAddress": "서울시 강남구 테헤란로",
"detailAddress": "000동 000호",
"zipCode": "00000"
},
"method": "카드"
"cancelReason": "변심"
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
@Configuration
public class JwtConfig {

@Value("${jwt.issuer}")
@Value("${booking-jwt.issuer}")
private String issuer;

@Value("${jwt.secret-key}")
@Value("${booking-jwt.secret-key}")
private String secretKey;

@Value("${jwt.expiry-seconds}")
@Value("${booking-jwt.expiry-seconds}")
private Long expirySeconds;

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ public class SecurityConfig {
@Bean
public SecurityFilterChain bookingFilterChain(HttpSecurity http) throws Exception {
List<RequestMatcher> permitAllMatchers = List.of(
new AntPathRequestMatcher("/bookings", HttpMethod.GET.toString()),
new AntPathRequestMatcher("/payments", HttpMethod.GET.toString()),
new AntPathRequestMatcher("/api/*/bookings/issue-session-id", HttpMethod.POST.toString()),
new AntPathRequestMatcher("/api/*/bookings/enter-queue", HttpMethod.POST.toString()),
new AntPathRequestMatcher("/api/*/bookings/order-in-queue", HttpMethod.GET.toString()),
new AntPathRequestMatcher("/api/*/bookings/issue-token", HttpMethod.POST.toString())
new AntPathRequestMatcher("/api/*/bookings/exit-queue", HttpMethod.POST.toString()),
new AntPathRequestMatcher("/api/*/bookings/issue-token", HttpMethod.POST.toString()),
new AntPathRequestMatcher("/api/*/bookings/**/cancel", HttpMethod.POST.toString()),
new AntPathRequestMatcher("/api/*/payments/**", HttpMethod.GET.toString()),
new AntPathRequestMatcher("/api/*/payments/**", HttpMethod.POST.toString())
);

return http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@
import java.util.Objects;
import java.util.Optional;

import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pgms.apibooking.common.exception.BookingErrorCode;
import com.pgms.apibooking.common.exception.BookingException;
import com.pgms.apibooking.common.jwt.BookingAuthToken;
import com.pgms.apibooking.config.TossPaymentConfig;
import com.pgms.apibooking.domain.booking.dto.request.BookingCancelRequest;
import com.pgms.apibooking.domain.booking.dto.request.BookingCreateRequest;
import com.pgms.apibooking.domain.booking.dto.request.DeliveryAddress;
import com.pgms.apibooking.domain.booking.dto.response.BookingCreateResponse;
import com.pgms.apibooking.domain.bookingqueue.repository.BookingQueueRepository;
import com.pgms.apibooking.domain.payment.dto.request.PaymentCancelRequest;
import com.pgms.apibooking.domain.payment.dto.request.RefundAccountRequest;
import com.pgms.apibooking.common.exception.BookingErrorCode;
import com.pgms.apibooking.common.exception.BookingException;
import com.pgms.apibooking.domain.payment.service.PaymentService;
import com.pgms.apibooking.common.jwt.BookingAuthToken;
import com.pgms.apibooking.domain.bookingqueue.repository.BookingQueueRepository;
import com.pgms.coredomain.domain.booking.Booking;
import com.pgms.coredomain.domain.booking.Payment;
import com.pgms.coredomain.domain.booking.PaymentMethod;
import com.pgms.coredomain.domain.booking.PaymentStatus;
import com.pgms.coredomain.domain.booking.ReceiptType;
import com.pgms.coredomain.domain.booking.Ticket;
import com.pgms.coredomain.domain.booking.repository.BookingRepository;
import com.pgms.coredomain.domain.booking.repository.TicketRepository;
import com.pgms.coredomain.domain.event.EventSeat;
import com.pgms.coredomain.domain.event.EventSeatStatus;
import com.pgms.coredomain.domain.event.EventTime;
import com.pgms.coredomain.domain.booking.Ticket;
import com.pgms.coredomain.domain.event.repository.EventSeatRepository;
import com.pgms.coredomain.domain.event.repository.EventTimeRepository;
import com.pgms.coredomain.domain.member.Member;
Expand Down Expand Up @@ -81,8 +82,7 @@ public BookingCreateResponse createBooking(BookingCreateRequest request, Long me

seats.forEach(seat -> seat.updateStatus(EventSeatStatus.BOOKED));

//TODO: 비동기 함수로 분리
bookingQueueRepository.remove(booking.getTime().getEvent().getId(), getCurrentSessionId());
removeSessionIdInBookingQueue(booking.getTime().getEvent().getId());

return BookingCreateResponse.of(booking, tossPaymentConfig.getSuccessUrl(), tossPaymentConfig.getFailUrl());
}
Expand Down Expand Up @@ -176,4 +176,9 @@ private String getCurrentSessionId() {
}
return null;
}

@Async
protected void removeSessionIdInBookingQueue(Long eventId) {
bookingQueueRepository.remove(eventId, getCurrentSessionId());
}
}
4 changes: 2 additions & 2 deletions api/api-booking/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ spring:
payment:
toss:
test-client-api-key: test_ck_Gv6LjeKD8aE1pdWDXXNw8wYxAdXy
test-secret-api-key: test_sk_tempSecretKey # 노출되면 안됨!! 임시값 넣어놓음
test-secret-api-key: test_sk_eqRGgYO1r5MNel9067jarQnN2Eya # 노출되면 안됨!! 임시값 넣어놓음
success-url: https://localhost:8080/api/v1/success
fail-url: https://localhost:8080/api/v1/fail

jwt:
booking-jwt:
issuer: booking
secret-key: EENY5W0eegTf1naQB2eDeyCLl5kRS2b8xa5c4qLdS0hmVjtbvo8tOyhPMcAmtPu
expiry-seconds: 420
Loading

0 comments on commit d7b9fc5

Please sign in to comment.