Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…park into member/227

# Conflicts:
#	db/conf.d/schema.sql
#	http/bingterpark.http
  • Loading branch information
eunbc committed Jan 12, 2024
2 parents 3fe3ce9 + 6eedeaf commit 71f78fa
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 246 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 코드를 위에서부터 하나씩 실행하시면 됩니다.
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
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
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
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@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<EventHallSeat> eventHallSeats = new ArrayList<>();

@Builder
public EventHall(String name, String address, List<EventHallSeat> 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<EventHallSeat> eventHallSeats = new ArrayList<>();

@Builder
public EventHall(String name, String address, List<EventHallSeat> 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();
}
}
6 changes: 5 additions & 1 deletion core/core-infra/src/main/resources/application-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -42,3 +42,7 @@ spring:
sql:
init:
mode: never

logging:
level:
org.hibernate.SQL: INFO
5 changes: 3 additions & 2 deletions core/core-infra/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- EventHall
INSERT INTO event_hall (event_name, address)
INSERT INTO event_hall (name, address)
VALUES ('고척스카이돔', '서울 구로구 경인로 430');

-- Event
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 71f78fa

Please sign in to comment.