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

refactor: 공연 도메인 ddl 컬럼 크기 조정 #236

Merged
merged 6 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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
@@ -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
107 changes: 53 additions & 54 deletions db/conf.d/schema.sql → db/initdb.d/1-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,82 @@ CREATE TABLE admin
status VARCHAR(255) 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 VARCHAR(255),
detail_address VARCHAR(255),
email VARCHAR(255) NOT NULL,
gender VARCHAR(255),
name VARCHAR(255) NOT NULL,
password VARCHAR(255),
phone_number VARCHAR(255),
provider VARCHAR(255),
role VARCHAR(255),
status VARCHAR(255) NOT NULL,
street_address VARCHAR(255),
zip_code VARCHAR(255)
);

CREATE TABLE event
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
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(255),
running_time INT,
started_at TIMESTAMP(6),
thumbnail TEXT,
title VARCHAR(255),
rating VARCHAR(255),
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 BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연장 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
address VARCHAR(255),
event_name VARCHAR(255)
address VARCHAR(255), -- 공연장 주소
name VARCHAR(50) -- 공연장 이름
);

CREATE TABLE event_hall_seat
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연장 좌석 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
name VARCHAR(255),
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 BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 이미지 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
url TEXT,
url TEXT, -- 이미지 url
event_id BIGINT,
FOREIGN KEY (event_id) REFERENCES event (id)
);

CREATE TABLE event_review
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 후기 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
content TEXT,
score INT,
content TEXT, -- 공연 후기 내용
score INT, -- 공연 후기 점수
event_id BIGINT,
member_id BIGINT,
FOREIGN KEY (event_id) REFERENCES event (id),
Expand All @@ -76,60 +97,38 @@ CREATE TABLE event_review

CREATE TABLE event_seat
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
id BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 좌석 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
name VARCHAR(255),
status VARCHAR(255),
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 BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 좌석 구역 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
price INT,
area_type VARCHAR(255),
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 BIGINT AUTO_INCREMENT PRIMARY KEY, -- 공연 회차 id
created_at TIMESTAMP(6),
updated_at TIMESTAMP(6),
ended_at TIMESTAMP(6),
round INT,
started_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 VARCHAR(255),
detail_address VARCHAR(255),
email VARCHAR(255) NOT NULL,
gender VARCHAR(255),
name VARCHAR(255) NOT NULL,
password VARCHAR(255),
phone_number VARCHAR(255),
provider VARCHAR(255),
role VARCHAR(255),
status VARCHAR(255) NOT NULL,
street_address VARCHAR(255),
zip_code VARCHAR(255)
);


-- 예매

CREATE TABLE IF NOT EXISTS booking
Expand Down
2 changes: 1 addition & 1 deletion db/initdb.d/data.sql → db/initdb.d/2-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
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
mysql:
image: mysql:latest
container_name: bingterpark
restart: always
environment:
MYSQL_ROOT_PASSWORD: root1234!
MYSQL_DATABASE: bingterpark
Expand Down
1 change: 1 addition & 0 deletions http/bingterpark.http
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Content-Type: application/json
### 공연장 등록
POST http://localhost:8080/api/v1/event-halls
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzM4NCJ9.eyJpZCI6Miwic3ViIjoiYWRtaW5AZXhhbXBsZS5jb20iLCJpYXQiOjE3MDUwMjQxNzgsImV4cCI6MTcwNTAyNTk3OCwiYXV0aG9yaXR5IjoiUk9MRV9BRE1JTiJ9.V5-9yIMRhoIB2ivtCvrZV7I4fTVvlkKyJ6nwA5UpijOolOj8xfc-6WevHDyn5hkc

{
"name": "잠실 종합운동장",
Expand Down
Binary file added img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading