Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 예매 도메인 DDL, swagger 작성 #235

Merged
merged 3 commits into from
Jan 12, 2024
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 @@ -25,17 +25,21 @@
import com.pgms.coredomain.response.ApiResponse;
import com.pgms.coresecurity.security.resolver.CurrentAccount;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v1/bookings")
@RequiredArgsConstructor
@Tag(name = "예매")
public class BookingController {

private final BookingService bookingService;

@Operation(summary = "예매 생성")
@PostMapping("/create")
public ResponseEntity<ApiResponse<BookingCreateResponse>> createBooking(
@CurrentAccount Long memberId,
Expand All @@ -52,6 +56,7 @@ public ResponseEntity<ApiResponse<BookingCreateResponse>> createBooking(
return ResponseEntity.created(location).body(response);
}

@Operation(summary = "예매 취소")
@PostMapping("/{id}/cancel")
public ResponseEntity<Void> cancelBooking(
@CurrentAccount Long memberId,
Expand All @@ -61,12 +66,14 @@ public ResponseEntity<Void> cancelBooking(
return ResponseEntity.noContent().build();
}

@Operation(summary = "예매 이탈")
@PostMapping("/{id}/exit")
public ResponseEntity<Void> exitBooking(@PathVariable String id) {
bookingService.exitBooking(id);
return ResponseEntity.noContent().build();
}

@Operation(summary = "내 예매 목록 조회")
@GetMapping
public ResponseEntity<ApiResponse<PageResponse<BookingsGetResponse>>> getBookings(
@CurrentAccount Long memberId,
Expand All @@ -78,6 +85,7 @@ public ResponseEntity<ApiResponse<PageResponse<BookingsGetResponse>>> getBooking
return ResponseEntity.ok().body(response);
}

@Operation(summary = "내 예매 상세 조회")
@GetMapping("/{id}")
public ResponseEntity<ApiResponse<BookingGetResponse>> getBooking(
@CurrentAccount Long memberId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,49 @@
import com.pgms.apibooking.domain.bookingqueue.service.BookingQueueService;
import com.pgms.coredomain.response.ApiResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v1/bookings")
@RequiredArgsConstructor
@Tag(name = "예매 대기열")
public class BookingQueueController {

private final BookingQueueService bookingQueueService;

@Operation(summary = "세션 아이디 발급")
@PostMapping("/issue-session-id")
public ResponseEntity<ApiResponse<SessionIdIssueResponse>> issueSessionId() {
ApiResponse<SessionIdIssueResponse> response = ApiResponse.ok(bookingQueueService.issueSessionId());
return ResponseEntity.ok(response);
}

@Operation(summary = "대기열 진입")
@PostMapping("/enter-queue")
public ResponseEntity<Void> enterQueue(@RequestBody @Valid BookingQueueEnterRequest request, @RequestAttribute("bookingSessionId") String bookingSessionId) {
bookingQueueService.enterQueue(request, bookingSessionId);
return ResponseEntity.noContent().build();
}

@Operation(summary = "내 대기 순서 확인")
@GetMapping("/order-in-queue")
public ResponseEntity<ApiResponse<OrderInQueueGetResponse>> getOrderInQueue(@RequestParam Long eventId, @RequestAttribute("bookingSessionId") String bookingSessionId) {
ApiResponse<OrderInQueueGetResponse> response =
ApiResponse.ok(bookingQueueService.getOrderInQueue(eventId, bookingSessionId));
return ResponseEntity.ok(response);
}

@Operation(summary = "예매 토큰 발급")
@PostMapping("/issue-token")
public ResponseEntity<ApiResponse<TokenIssueResponse>> issueToken(@RequestBody @Valid TokenIssueRequest request, @RequestAttribute("bookingSessionId") String bookingSessionId) {
ApiResponse<TokenIssueResponse> response = ApiResponse.ok(bookingQueueService.issueToken(request, bookingSessionId));
return ResponseEntity.ok(response);
}

@Operation(summary = "대기열 이탈")
@PostMapping("/exit-queue")
public ResponseEntity<Void> exitQueue(@RequestBody @Valid BookingQueueExitRequest request, @RequestAttribute("bookingSessionId") String bookingSessionId) {
bookingQueueService.exitQueue(request, bookingSessionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
import com.pgms.apibooking.domain.payment.service.PaymentService;
import com.pgms.coredomain.response.ApiResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v1/payments")
@RequiredArgsConstructor
@Tag(name = "결제")
public class PaymentController {

private final PaymentService paymentService;

@Operation(summary = "결제 성공 처리")
@GetMapping("/success")
public ResponseEntity<ApiResponse> confirmPaymentSuccess(
@RequestParam String paymentKey,
Expand All @@ -31,6 +35,7 @@ public ResponseEntity<ApiResponse> confirmPaymentSuccess(
return ResponseEntity.ok(ApiResponse.ok(paymentService.successPayment(paymentKey, bookingId, amount)));
}

@Operation(summary = "결제 실패 처리")
@GetMapping("/fail")
public ResponseEntity<ApiResponse> confirmPaymentFail(
@RequestParam(name = "code") String errorCode,
Expand All @@ -42,6 +47,7 @@ public ResponseEntity<ApiResponse> confirmPaymentFail(
return ResponseEntity.ok(response);
}

@Operation(summary = "가상계좌 입금 확인 웹훅")
@PostMapping("/virtual/income")
public ResponseEntity<Void> confirmVirtualAccountIncome(@RequestBody ConfirmVirtualIncomeRequest request) {
System.out.println(request.createdAt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,34 @@
import com.pgms.coredomain.response.ApiResponse;
import com.pgms.coresecurity.security.resolver.CurrentAccount;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v1/seats")
@RequiredArgsConstructor
@Tag(name = "좌석")
public class SeatController {

private final SeatService seatService;

@Operation(summary = "좌석 목록 조회")
@GetMapping
public ResponseEntity<ApiResponse<List<AreaResponse>>> getSeats(@ModelAttribute @Valid SeatsGetRequest request) {
ApiResponse<List<AreaResponse>> response = ApiResponse.ok(seatService.getSeats(request));
return ResponseEntity.ok().body(response);
}

@Operation(summary = "좌석 선택")
@PostMapping("/{seatId}/select")
public ResponseEntity<Void> selectSeat(@PathVariable Long seatId, @CurrentAccount Long memberId) {
seatService.selectSeat(seatId, memberId);
return ResponseEntity.noContent().build();
}

@Operation(summary = "좌석 선택 해제")
@PostMapping("/{seatId}/deselect")
public ResponseEntity<Void> deselectSeat(@PathVariable Long seatId, @CurrentAccount Long memberId) {
seatService.deselectSeat(seatId, memberId);
Expand Down
137 changes: 74 additions & 63 deletions db/conf.d/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,6 @@ CREATE TABLE admin
status VARCHAR(255) NOT NULL
);

CREATE TABLE booking
(
id VARCHAR(255) NOT NULL PRIMARY KEY,
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
amount INT NOT NULL,
booking_name VARCHAR(255) NOT NULL,
buyer_name VARCHAR(255) NOT NULL,
buyer_phone_number VARCHAR(255) NOT NULL,
detail_address VARCHAR(255),
receipt_type VARCHAR(255) NOT NULL,
recipient_name VARCHAR(255),
recipient_phone_number VARCHAR(255),
status VARCHAR(255) NOT NULL,
street_address VARCHAR(255),
zip_code VARCHAR(255),
member_id BIGINT NOT NULL,
time_id BIGINT NOT NULL
);

CREATE TABLE booking_cancel
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
amount INT NOT NULL,
created_by VARCHAR(255) NOT NULL,
reason VARCHAR(255) NOT NULL,
booking_id VARCHAR(255) NOT NULL
);

CREATE TABLE event
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
Expand Down Expand Up @@ -160,40 +129,82 @@ CREATE TABLE member
zip_code VARCHAR(255)
);

CREATE TABLE payment

-- 예매

CREATE TABLE IF NOT EXISTS booking
(
id CHAR(13) NOT NULL PRIMARY KEY, -- 예매 번호
amount INT UNSIGNED NOT NULL, -- 결제 금액
booking_name VARCHAR(255) NOT NULL, -- 예매 명
status VARCHAR(20) NOT NULL, -- 예매 상태
buyer_name VARCHAR(100) NOT NULL, -- 구매자 명
buyer_phone_number VARCHAR(20) NOT NULL, -- 구매자 전화번호
receipt_type VARCHAR(20) NOT NULL, -- 티켓 수령 타입
recipient_name VARCHAR(100), -- 수령인 명
recipient_phone_number VARCHAR(20), -- 수령인 전화번호
street_address VARCHAR(255), -- 수령지 도로명 주소
detail_address VARCHAR(255), -- 수령지 상세 주소
zip_code CHAR(5), -- 수령지 우편 번호
member_id BIGINT UNSIGNED NOT NULL, -- 회원 id
time_id BIGINT UNSIGNED NOT NULL, -- 공연 회차 id
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX booking_idx_buyer_name (buyer_name),
INDEX booking_idx_buyer_phone_number (buyer_phone_number),
INDEX booking_idx_member_id (member_id),
INDEX booking_idx_time_id (time_id),
INDEX booking_idx_created_at (created_at),
INDEX booking_idx_updated_at (updated_at)
);

CREATE TABLE IF NOT EXISTS payment
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
account_number VARCHAR(255),
amount INT NOT NULL,
approved_at TIMESTAMP(6),
bank_code VARCHAR(255),
card_issuer VARCHAR(255),
card_number VARCHAR(255),
depositor_name VARCHAR(255),
due_date TIMESTAMP(6),
failed_msg VARCHAR(255),
installment_plan_months INT,
is_interest_free BOOLEAN,
method VARCHAR(255),
payment_key VARCHAR(255),
refund_account_number VARCHAR(255),
refund_bank_code VARCHAR(255),
refund_holder_name VARCHAR(255),
requested_at TIMESTAMP(6),
status VARCHAR(255) NOT NULL,
booking_id VARCHAR(255),
FOREIGN KEY (booking_id) REFERENCES booking (id)
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, -- 결제 id
payment_key VARCHAR(50), -- 결제 키
status VARCHAR(20) NOT NULL, -- 결제 상태
amount INT UNSIGNED NOT NULL, -- 결제 가격
method VARCHAR(20), -- 결제 수단
card_issuer VARCHAR(20), -- 카드 발급사
card_number VARCHAR(20), -- 카드 번호
installment_plan_months INT UNSIGNED, -- 할부 개월 수
is_interest_free BOOLEAN, -- 무이자 여부
bank_code CHAR(4), -- 은행 코드
account_number VARCHAR(20), -- 가상 계좌 번호
depositor_name VARCHAR(20), -- 입금자 명
due_date DATETIME, -- 입금 기한
refund_account_number VARCHAR(20), -- 환불 계좌 번호
refund_bank_code CHAR(2), -- 환불 은행 코드
refund_holder_name VARCHAR(20), -- 환불 계좌 예금주
failed_msg VARCHAR(255), -- 결제 실패 메시지
requested_at DATETIME, -- 결제 요청 날짜
approved_at DATETIME, -- 결제 승인 날짜
booking_id CHAR(13) NOT NULL, -- 예매 번호
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX payment_idx_payment_key (payment_key),
INDEX payment_idx_booking_id (booking_id)
);

CREATE TABLE ticket
CREATE TABLE IF NOT EXISTS ticket
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
booking_id VARCHAR(255) NOT NULL,
seat_id BIGINT NOT NULL,
FOREIGN KEY (booking_id) REFERENCES booking (id),
FOREIGN KEY (seat_id) REFERENCES event_seat (id)
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, -- 티켓 id
seat_id BIGINT UNSIGNED NOT NULL, -- 공연 좌석 id
booking_id CHAR(13) NOT NULL, -- 예매 번호
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX ticket_idx_seat_id (seat_id),
INDEX ticket_idx_booking_id (booking_id)
);

CREATE TABLE IF NOT EXISTS booking_cancel
(
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, -- 예매 취소 id
amount INT UNSIGNED NOT NULL, -- 환불 금액
reason VARCHAR(100) NOT NULL, -- 취소 사유
created_by VARCHAR(50) NOT NULL, -- 취소 요청자
booking_id CHAR(13) NOT NULL, -- 예매 번호
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX booking_cancel_idx_booking_id (booking_id)
);