diff --git a/README.md b/README.md index 226c5998..a038a26c 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,46 @@ ## Bingterpark + [노션 페이지](https://www.notion.so/backend-devcourse/2-BingterPark-4ecfb3943d9c4a8f9bb83f72876b6a80) [ERD](https://www.erdcloud.com/d/ZadArGCaQXFcxZuu8) + ### 모듈 구조 + +![img.png](img.png) + #### api + - api-member -회원 도메인 + 회원 도메인 - api-event -공연 도메인 + 공연 도메인 - api-booking -예매 도메인 + 예매 도메인 + #### batch + 스프링 배치 모듈 + #### core + - core-domain -JPA 엔티티, 리포지토리 + JPA 엔티티, 리포지토리 - core-infra -queryDsl, RDB 설정 파일 + queryDsl, RDB 설정 파일 - core-infra-es -elastic search 설정 파일, document, searchRepository + elastic search 설정 파일, document, searchRepository - core-security -spring security 설정 파일 + spring security 설정 파일 + ## 실행 방법 + 1. git clone 2. RDB, 레디스 실행 ```docker-compose up -d``` 3. api-event 모듈로 이동 ```cd /api/api-event``` 4. 엘라스틱 서치 도커 이미지 빌드 ```docker build -t el:0.1 -f ./Dockerfile .``` 5. ELK 스택 실행 ```docker-compose up -d``` 6. api-booking, api-event, api-member 각 모듈에서 스프링 어플리케이션 실행 + ## 테스트 방법 + - 통합 http 테스트는 /http/bingterpark.http에 있습니다. - 어드민 플로우, 유저 플로우 http 코드를 위에서부터 하나씩 실행하시면 됩니다. diff --git a/api/api-booking/src/main/java/com/pgms/apibooking/domain/booking/controller/BookingController.java b/api/api-booking/src/main/java/com/pgms/apibooking/domain/booking/controller/BookingController.java index a628c691..cf569cf8 100644 --- a/api/api-booking/src/main/java/com/pgms/apibooking/domain/booking/controller/BookingController.java +++ b/api/api-booking/src/main/java/com/pgms/apibooking/domain/booking/controller/BookingController.java @@ -25,6 +25,8 @@ 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; @@ -32,10 +34,12 @@ @RestController @RequestMapping("/api/v1/bookings") @RequiredArgsConstructor +@Tag(name = "예매") public class BookingController { private final BookingService bookingService; + @Operation(summary = "예매 생성") @PostMapping("/create") public ResponseEntity> createBooking( @CurrentAccount Long memberId, @@ -52,6 +56,7 @@ public ResponseEntity> createBooking( return ResponseEntity.created(location).body(response); } + @Operation(summary = "예매 취소") @PostMapping("/{id}/cancel") public ResponseEntity cancelBooking( @CurrentAccount Long memberId, @@ -61,12 +66,14 @@ public ResponseEntity cancelBooking( return ResponseEntity.noContent().build(); } + @Operation(summary = "예매 이탈") @PostMapping("/{id}/exit") public ResponseEntity exitBooking(@PathVariable String id) { bookingService.exitBooking(id); return ResponseEntity.noContent().build(); } + @Operation(summary = "내 예매 목록 조회") @GetMapping public ResponseEntity>> getBookings( @CurrentAccount Long memberId, @@ -78,6 +85,7 @@ public ResponseEntity>> getBooking return ResponseEntity.ok().body(response); } + @Operation(summary = "내 예매 상세 조회") @GetMapping("/{id}") public ResponseEntity> getBooking( @CurrentAccount Long memberId, diff --git a/api/api-booking/src/main/java/com/pgms/apibooking/domain/bookingqueue/controller/BookingQueueController.java b/api/api-booking/src/main/java/com/pgms/apibooking/domain/bookingqueue/controller/BookingQueueController.java index d788d98e..7fb7ffbf 100644 --- a/api/api-booking/src/main/java/com/pgms/apibooking/domain/bookingqueue/controller/BookingQueueController.java +++ b/api/api-booking/src/main/java/com/pgms/apibooking/domain/bookingqueue/controller/BookingQueueController.java @@ -18,28 +18,34 @@ 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> issueSessionId() { ApiResponse response = ApiResponse.ok(bookingQueueService.issueSessionId()); return ResponseEntity.ok(response); } + @Operation(summary = "대기열 진입") @PostMapping("/enter-queue") public ResponseEntity 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> getOrderInQueue(@RequestParam Long eventId, @RequestAttribute("bookingSessionId") String bookingSessionId) { ApiResponse response = @@ -47,12 +53,14 @@ public ResponseEntity> getOrderInQueue(@Req return ResponseEntity.ok(response); } + @Operation(summary = "예매 토큰 발급") @PostMapping("/issue-token") public ResponseEntity> issueToken(@RequestBody @Valid TokenIssueRequest request, @RequestAttribute("bookingSessionId") String bookingSessionId) { ApiResponse response = ApiResponse.ok(bookingQueueService.issueToken(request, bookingSessionId)); return ResponseEntity.ok(response); } + @Operation(summary = "대기열 이탈") @PostMapping("/exit-queue") public ResponseEntity exitQueue(@RequestBody @Valid BookingQueueExitRequest request, @RequestAttribute("bookingSessionId") String bookingSessionId) { bookingQueueService.exitQueue(request, bookingSessionId); diff --git a/api/api-booking/src/main/java/com/pgms/apibooking/domain/payment/controller/PaymentController.java b/api/api-booking/src/main/java/com/pgms/apibooking/domain/payment/controller/PaymentController.java index 180b2b11..6ada834f 100644 --- a/api/api-booking/src/main/java/com/pgms/apibooking/domain/payment/controller/PaymentController.java +++ b/api/api-booking/src/main/java/com/pgms/apibooking/domain/payment/controller/PaymentController.java @@ -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 confirmPaymentSuccess( @RequestParam String paymentKey, @@ -31,6 +35,7 @@ public ResponseEntity confirmPaymentSuccess( return ResponseEntity.ok(ApiResponse.ok(paymentService.successPayment(paymentKey, bookingId, amount))); } + @Operation(summary = "결제 실패 처리") @GetMapping("/fail") public ResponseEntity confirmPaymentFail( @RequestParam(name = "code") String errorCode, @@ -42,6 +47,7 @@ public ResponseEntity confirmPaymentFail( return ResponseEntity.ok(response); } + @Operation(summary = "가상계좌 입금 확인 웹훅") @PostMapping("/virtual/income") public ResponseEntity confirmVirtualAccountIncome(@RequestBody ConfirmVirtualIncomeRequest request) { System.out.println(request.createdAt()); diff --git a/api/api-booking/src/main/java/com/pgms/apibooking/domain/seat/controller/SeatController.java b/api/api-booking/src/main/java/com/pgms/apibooking/domain/seat/controller/SeatController.java index 1553eb4c..b8e0680b 100644 --- a/api/api-booking/src/main/java/com/pgms/apibooking/domain/seat/controller/SeatController.java +++ b/api/api-booking/src/main/java/com/pgms/apibooking/domain/seat/controller/SeatController.java @@ -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>> getSeats(@ModelAttribute @Valid SeatsGetRequest request) { ApiResponse> response = ApiResponse.ok(seatService.getSeats(request)); return ResponseEntity.ok().body(response); } + @Operation(summary = "좌석 선택") @PostMapping("/{seatId}/select") public ResponseEntity selectSeat(@PathVariable Long seatId, @CurrentAccount Long memberId) { seatService.selectSeat(seatId, memberId); return ResponseEntity.noContent().build(); } + @Operation(summary = "좌석 선택 해제") @PostMapping("/{seatId}/deselect") public ResponseEntity deselectSeat(@PathVariable Long seatId, @CurrentAccount Long memberId) { seatService.deselectSeat(seatId, memberId); diff --git a/core/core-domain/src/main/java/com/pgms/coredomain/domain/event/EventHall.java b/core/core-domain/src/main/java/com/pgms/coredomain/domain/event/EventHall.java index 1968a63b..fde71288 100644 --- a/core/core-domain/src/main/java/com/pgms/coredomain/domain/event/EventHall.java +++ b/core/core-domain/src/main/java/com/pgms/coredomain/domain/event/EventHall.java @@ -1,12 +1,24 @@ package com.pgms.coredomain.domain.event; -import com.pgms.coredomain.domain.common.BaseEntity; -import jakarta.persistence.*; -import lombok.*; - import java.util.ArrayList; import java.util.List; +import com.pgms.coredomain.domain.common.BaseEntity; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + @Entity @Getter @AllArgsConstructor @@ -14,36 +26,37 @@ @Table(name = "event_hall") public class EventHall extends BaseEntity { - @Id - @Column(name = "id") - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "event_name") - private String name; - - @Column(name = "address") - private String address; - - @OneToMany(mappedBy = "eventHall", cascade = CascadeType.ALL, orphanRemoval = true) - private List eventHallSeats = new ArrayList<>(); - - @Builder - public EventHall(String name, String address, List eventHallSeats) { - this.name = name; - this.address = address; - this.eventHallSeats = eventHallSeats; - setEventHallSeatsEventHall(); - } - - public void setEventHallSeatsEventHall(){ - if(this.eventHallSeats == null) return; - this.eventHallSeats.forEach(eventHallSeat -> eventHallSeat.setEventHall(this)); - } - - public void updateEventHall(EventHallEdit eventHallEdit){ - this.name = eventHallEdit.getName(); - this.address = eventHallEdit.getAddress(); - this.eventHallSeats = eventHallEdit.getEventHallSeats(); - } + @Id + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name") + private String name; + + @Column(name = "address") + private String address; + + @OneToMany(mappedBy = "eventHall", cascade = CascadeType.ALL, orphanRemoval = true) + private List eventHallSeats = new ArrayList<>(); + + @Builder + public EventHall(String name, String address, List eventHallSeats) { + this.name = name; + this.address = address; + this.eventHallSeats = eventHallSeats; + setEventHallSeatsEventHall(); + } + + public void setEventHallSeatsEventHall() { + if (this.eventHallSeats == null) + return; + this.eventHallSeats.forEach(eventHallSeat -> eventHallSeat.setEventHall(this)); + } + + public void updateEventHall(EventHallEdit eventHallEdit) { + this.name = eventHallEdit.getName(); + this.address = eventHallEdit.getAddress(); + this.eventHallSeats = eventHallEdit.getEventHallSeats(); + } } diff --git a/core/core-infra/src/main/resources/application-infra.yml b/core/core-infra/src/main/resources/application-infra.yml index 6150fc0d..44338181 100644 --- a/core/core-infra/src/main/resources/application-infra.yml +++ b/core/core-infra/src/main/resources/application-infra.yml @@ -30,7 +30,7 @@ spring: on-profile: prod datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8 + url: jdbc:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8c:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8 username: root password: root1234! jpa: @@ -42,3 +42,7 @@ spring: sql: init: mode: never + +logging: + level: + org.hibernate.SQL: INFO diff --git a/core/core-infra/src/main/resources/data.sql b/core/core-infra/src/main/resources/data.sql index 11d9b3b2..3e53dc8a 100644 --- a/core/core-infra/src/main/resources/data.sql +++ b/core/core-infra/src/main/resources/data.sql @@ -1,5 +1,5 @@ -- EventHall -INSERT INTO event_hall (event_name, address) +INSERT INTO event_hall (name, address) VALUES ('고척스카이돔', '서울 구로구 경인로 430'); -- Event @@ -95,7 +95,8 @@ INSERT INTO payment (booking_id, approved_at, created_at, updated_at) -VALUES ('bookingTestId', 180000, 'CARD', 'HYUNDAI', '11111111****111*', 0, false, 'paymentkey', 'CANCELED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +VALUES ('bookingTestId', 180000, 'CARD', 'HYUNDAI', '11111111****111*', 0, false, 'paymentkey', 'CANCELED', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); -- Booking Cancel INSERT INTO booking_cancel (booking_id, amount, reason, created_by, created_at, updated_at) diff --git a/db/conf.d/schema.sql b/db/conf.d/schema.sql deleted file mode 100644 index 827693dc..00000000 --- a/db/conf.d/schema.sql +++ /dev/null @@ -1,199 +0,0 @@ -CREATE TABLE admin -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - last_login_at TIMESTAMP(6) NOT NULL, - last_password_updated_at TIMESTAMP(6) NOT NULL, - email VARCHAR(50) NOT NULL, - name VARCHAR(20) NOT NULL, - password VARCHAR(100) NOT NULL, - phone_number VARCHAR(20) NOT NULL, - role VARCHAR(20), - status VARCHAR(10) 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, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - average_score FLOAT(53), - booking_ended_at TIMESTAMP(6), - booking_started_at TIMESTAMP(6), - description TEXT, - ended_at TIMESTAMP(6), - genre VARCHAR(255), - running_time INT, - started_at TIMESTAMP(6), - thumbnail TEXT, - title VARCHAR(255), - rating VARCHAR(255), - event_hall_id BIGINT -); - -CREATE TABLE event_hall -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - address VARCHAR(255), - event_name VARCHAR(255) -); - -CREATE TABLE event_hall_seat -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - name VARCHAR(255), - eventhall_id BIGINT, - FOREIGN KEY (eventhall_id) REFERENCES event_hall (id) -); - -CREATE TABLE event_image -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - url TEXT, - event_id BIGINT, - FOREIGN KEY (event_id) REFERENCES event (id) -); - -CREATE TABLE event_review -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - content TEXT, - score INT, - event_id BIGINT, - member_id BIGINT, - FOREIGN KEY (event_id) REFERENCES event (id), - FOREIGN KEY (member_id) REFERENCES member (id) -); - -CREATE TABLE event_seat -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - name VARCHAR(255), - status VARCHAR(255), - event_seat_area_id BIGINT, - event_time_id BIGINT -); - -CREATE TABLE event_seat_area -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - price INT, - area_type VARCHAR(255), - event_id BIGINT, - FOREIGN KEY (event_id) REFERENCES event (id) -); - -CREATE TABLE event_time -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - ended_at TIMESTAMP(6), - round INT, - started_at TIMESTAMP(6), - event_id BIGINT, - FOREIGN KEY (event_id) REFERENCES event (id) -); - -CREATE TABLE member -( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - created_at TIMESTAMP(6), - updated_at TIMESTAMP(6), - last_login_at TIMESTAMP(6) NOT NULL, - last_password_updated_at TIMESTAMP(6) NOT NULL, - birth_date DATE, - detail_address VARCHAR(50), - email VARCHAR(50) NOT NULL, - gender VARCHAR(10), - name VARCHAR(20) NOT NULL, - password VARCHAR(100), - phone_number VARCHAR(20), - provider VARCHAR(10), - role VARCHAR(20), - status VARCHAR(10) NOT NULL, - street_address VARCHAR(50), - zip_code VARCHAR(5) -); - -CREATE TABLE 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) -); - -CREATE TABLE 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) -); diff --git a/db/initdb.d/1-schema.sql b/db/initdb.d/1-schema.sql new file mode 100644 index 00000000..1c7c6ce3 --- /dev/null +++ b/db/initdb.d/1-schema.sql @@ -0,0 +1,209 @@ +CREATE TABLE admin +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + last_login_at TIMESTAMP(6) NOT NULL, + last_password_updated_at TIMESTAMP(6) NOT NULL, + email VARCHAR(50) NOT NULL, + name VARCHAR(20) NOT NULL, + password VARCHAR(100) NOT NULL, + phone_number VARCHAR(20) NOT NULL, + role VARCHAR(20), + status VARCHAR(10) NOT NULL +); + +CREATE TABLE member +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + last_login_at TIMESTAMP(6) NOT NULL, + last_password_updated_at TIMESTAMP(6) NOT NULL, + birth_date DATE, + detail_address VARCHAR(50), + email VARCHAR(50) NOT NULL, + gender VARCHAR(10), + name VARCHAR(20) NOT NULL, + password VARCHAR(100), + phone_number VARCHAR(20), + provider VARCHAR(10), + role VARCHAR(20), + status VARCHAR(10) NOT NULL, + street_address VARCHAR(50), + zip_code VARCHAR(5) +); + +CREATE TABLE event +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + average_score FLOAT(53), -- 공연 평점 평균 + booking_ended_at TIMESTAMP(6), -- 예매 시작일 + booking_started_at TIMESTAMP(6), -- 예매 종료일 + description TEXT, -- 공연 상세 설명 + ended_at TIMESTAMP(6), -- 공연 종료일 + genre VARCHAR(50), -- 장르 + running_time INT, -- 상영 시간 + started_at TIMESTAMP(6), -- 공연 시작일 + thumbnail TEXT, -- 공연 썸네일 + title VARCHAR(100), -- 공연 제목 + rating VARCHAR(50), -- 관람 등급 + event_hall_id BIGINT +); + +CREATE TABLE event_hall +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연장 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + address VARCHAR(255), -- 공연장 주소 + name VARCHAR(50) -- 공연장 이름 +); + +CREATE TABLE event_hall_seat +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연장 좌석 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + name VARCHAR(20), -- 공연장 좌석 이름 + eventhall_id BIGINT, + FOREIGN KEY (eventhall_id) REFERENCES event_hall (id) +); + +CREATE TABLE event_image +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 이미지 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + url TEXT, -- 이미지 url + event_id BIGINT, + FOREIGN KEY (event_id) REFERENCES event (id) +); + +CREATE TABLE event_review +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 후기 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + content TEXT, -- 공연 후기 내용 + score INT, -- 공연 후기 점수 + event_id BIGINT, + member_id BIGINT, + FOREIGN KEY (event_id) REFERENCES event (id), + FOREIGN KEY (member_id) REFERENCES member (id) +); + +CREATE TABLE event_seat +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 좌석 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + name VARCHAR(20), -- 좌석 이름 + status VARCHAR(50), -- 좌석 상태 + event_seat_area_id BIGINT, + event_time_id BIGINT +); + +CREATE TABLE event_seat_area +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 좌석 구역 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + price INT, -- 구역별 가격 + area_type VARCHAR(50), -- 구역 타입 + event_id BIGINT, + FOREIGN KEY (event_id) REFERENCES event (id) +); + +CREATE TABLE event_time +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 회차 id + created_at TIMESTAMP(6), + updated_at TIMESTAMP(6), + ended_at TIMESTAMP(6), -- 회차 종료 시간 + round INT, -- 회차 + started_at TIMESTAMP(6), -- 회차 시작 시간 + event_id BIGINT, + FOREIGN KEY (event_id) REFERENCES event (id) +); + +-- 예매 + +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 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 IF NOT EXISTS ticket +( + 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) +); diff --git a/db/initdb.d/data.sql b/db/initdb.d/2-data.sql similarity index 98% rename from db/initdb.d/data.sql rename to db/initdb.d/2-data.sql index 4c85e874..02156cbc 100644 --- a/db/initdb.d/data.sql +++ b/db/initdb.d/2-data.sql @@ -1,5 +1,5 @@ -- EventHall -INSERT INTO event_hall (event_name, address) +INSERT INTO event_hall (name, address) VALUES ('고척스카이돔', '서울 구로구 경인로 430'); -- Event diff --git a/docker-compose.yml b/docker-compose.yml index 01ef5165..7145b80c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: mysql: image: mysql:latest container_name: bingterpark + restart: always environment: MYSQL_ROOT_PASSWORD: root1234! MYSQL_DATABASE: bingterpark diff --git a/img.png b/img.png new file mode 100644 index 00000000..aa74979f Binary files /dev/null and b/img.png differ