diff --git a/cinema/.gitattributes b/cinema/.gitattributes new file mode 100644 index 000000000..8af972cde --- /dev/null +++ b/cinema/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/cinema/.gitignore b/cinema/.gitignore new file mode 100644 index 000000000..5a979af6f --- /dev/null +++ b/cinema/.gitignore @@ -0,0 +1,40 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Kotlin ### +.kotlin diff --git a/cinema/ReadMe.md b/cinema/ReadMe.md new file mode 100644 index 000000000..13ad4d14d --- /dev/null +++ b/cinema/ReadMe.md @@ -0,0 +1,119 @@ +# 프로젝트 README + +## 프로젝트 소개 +이 프로젝트는 영화 상영 정보와 관련된 기능을 제공하는 **멀티 모듈 프로젝트**입니다. 영화관, 영화, 상영 일정, 상영관 등의 정보를 효율적으로 관리하고 제공하는 시스템으로 설계되었습니다. 코드는 Kotlin과 Spring Boot를 기반으로 작성되었으며, 도메인 중심 설계를 적용하였습니다. + +--- + +## 모듈 구조 + +### 1. **`cinema-domain`** +- **역할:** + - 프로젝트의 핵심 비즈니스 로직과 엔티티가 정의된 모듈입니다. + - 데이터베이스와의 상호작용을 위한 JPA 엔티티와 Repository를 포함합니다. +- **주요 패키지 구성:** + - `cinema`: 영화관 정보 (Cinema) + - `movie`: 영화 정보 (Movie, Genre, MovieRating 등) + - `schedule`: 영화 상영 일정 (MovieSchedule) + - `theater`: 상영관 정보 (Theater) + - `infra.jpa`: JPA Repository 및 QueryDSL 설정 + +### 2. **`cinema-api`** +- **역할:** + - 외부 사용자에게 API를 제공하는 모듈입니다. + - Controller와 DTO 계층을 포함하여 클라이언트와의 인터페이스를 담당합니다. +- **주요 패키지 구성:** + - `application`: 비즈니스 로직을 처리하는 Service 계층 + - `interface`: API 요청을 처리하는 Controller와 DTO 정의 + +### 3. **`cinema-admin`** +- **역할:** + - 관리자용 기능(예: 상영 스케줄 관리)을 제공하는 모듈입니다. + +--- + +## 아키텍처 설명 + +### 전체 아키텍처 + +- **멀티 모듈 설계:** + - `cinema-domain`: 핵심 도메인 로직과 데이터 액세스를 처리합니다. + - `cinema-api`: 사용자 요청을 처리하고 비즈니스 로직을 호출합니다. + - `cinema-admin`: 관리자 기능을 제공합니다. + +- **계층 구조:** + - **Controller (API 모듈):** 사용자 요청을 받아 Service 계층으로 전달합니다. + - **Service (Domain 모듈):** 비즈니스 로직을 처리하며, Repository와 상호작용합니다. + - **Repository (Domain 모듈):** 데이터베이스와 직접적으로 통신합니다. + +### QueryDSL 적용 +- `cinema-domain` 모듈에 QueryDSL을 설정하여 동적 쿼리를 지원합니다. +- `MovieScheduleRepositoryCustom` 인터페이스와 `MovieScheduleRepositoryCustomImpl` 구현체를 통해 확장된 Repository 기능을 제공합니다. + +--- + +## 데이터베이스 테이블 설계 + +### 주요 테이블 + +#### 1. `cinema` +- **영화관 정보를 저장** +- 주요 컬럼: + - `id` (PK): 영화관 ID + - `name`: 영화관 이름 + - `address`: 영화관 주소 + - `contact_number`: 연락처 + +#### 2. `movie` +- **영화 정보를 저장** +- 주요 컬럼: + - `id` (PK): 영화 ID + - `title`: 영화 제목 + - `genre`: 영화 장르 + - `movie_rating`: 영상물 등급 + - `release_date`: 개봉일 + - `running_time_minutes`: 러닝 타임 + - `thumbnail_url`: 포스터 URL + +#### 3. `theater` +- **상영관 정보를 저장** +- 주요 컬럼: + - `id` (PK): 상영관 ID + - `title`: 상영관 이름 + - `cinema_id` (FK): 영화관 ID + +#### 4. `movie_schedule` +- **영화 상영 일정을 저장** +- 주요 컬럼: + - `id` (PK): 상영 일정 ID + - `start_at`: 상영 시작 시간 + - `end_at`: 상영 종료 시간 + - `movie_id` (FK): 영화 ID + - `theater_id` (FK): 상영관 ID + - `cinema_id` (FK): 영화관 ID + +--- + +## 실행 방법 +``` bash +docker-compose -f compose.yaml up -d + +``` + +## 테스트 +http.movie.http + +## 고민포인트 + +#### UI에서 제공해준 페이지네이션 + +UI는 영화와 상영관 단위로 리스트를 제공하며, 하위에 시간표를 표시해야 했습니다. +하지만 페이지네이션을 고려하면 (영화, 상영관) 의 수가 요청한 수를 제공할 수있는 구조여야 합니다. + +최초 접근 방법은 고유한 영화와 상영관 쌍을 먼저 뽑은 후, 시간표를 추가 쿼리로 조회하려 했습니다. +그러나 전체 정렬을 movie의 개봉일 기준으로 해야 했기 때문에 DISTINCT를 사용할 수 없었습니다. + +최종 대안: + +상영관 정보를 시간표와 동일한 위계로 내려 그룹핑을 애플리케이션 레벨에서 처리했습니다. +이를 통해 영화 개봉일로 정렬하면서도 UI 요구사항을 만족시킬 수 있었습니다. \ No newline at end of file diff --git a/cinema/build.gradle.kts b/cinema/build.gradle.kts new file mode 100644 index 000000000..aab69be7a --- /dev/null +++ b/cinema/build.gradle.kts @@ -0,0 +1,66 @@ +plugins { + kotlin("kapt") version "2.1.0" + kotlin("jvm") version "1.9.25" + kotlin("plugin.spring") version "1.9.25" + id("org.springframework.boot") version "3.4.1" + id("io.spring.dependency-management") version "1.1.7" + kotlin("plugin.jpa") version "1.9.25" +} + +group = "com.study" +version = "0.0.1-SNAPSHOT" + + + +allprojects { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +subprojects { + apply { + plugin("org.jetbrains.kotlin.jvm") + plugin("org.jetbrains.kotlin.kapt") + plugin("org.springframework.boot") + plugin("io.spring.dependency-management") + plugin("org.jetbrains.kotlin.plugin.jpa") + plugin("org.jetbrains.kotlin.plugin.spring") + } + dependencyManagement { + imports { + mavenBom("com.querydsl:querydsl-bom:5.1.0") + } + } + + dependencies { + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("org.jetbrains.kotlin:kotlin-reflect") + developmentOnly("org.springframework.boot:spring-boot-docker-compose") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + } + + kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") + } + } + + java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + } + + allOpen { + annotation("jakarta.persistence.Entity") + annotation("jakarta.persistence.MappedSuperclass") + annotation("jakarta.persistence.Embeddable") + } + + tasks.withType { + useJUnitPlatform() + } + } \ No newline at end of file diff --git a/cinema/cinema-admin/build.gradle.kts b/cinema/cinema-admin/build.gradle.kts new file mode 100644 index 000000000..e6b059640 --- /dev/null +++ b/cinema/cinema-admin/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + java + id("org.springframework.boot") + id("io.spring.dependency-management") +} + + +dependencies { + implementation(project(":cinema-domain")) + implementation("org.springframework.boot:spring-boot-starter-web") + testImplementation("org.springframework.boot:spring-boot-starter-test") +} \ No newline at end of file diff --git a/cinema/cinema-admin/src/main/java/com/study/cinema/CinemaAdminApplication.java b/cinema/cinema-admin/src/main/java/com/study/cinema/CinemaAdminApplication.java new file mode 100644 index 000000000..aecc61638 --- /dev/null +++ b/cinema/cinema-admin/src/main/java/com/study/cinema/CinemaAdminApplication.java @@ -0,0 +1,13 @@ +package com.study.cinema; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CinemaAdminApplication { + + public static void main(String[] args) { + SpringApplication.run(CinemaAdminApplication.class, args); + } + +} diff --git a/cinema/cinema-admin/src/main/resources/application.yaml b/cinema/cinema-admin/src/main/resources/application.yaml new file mode 100644 index 000000000..2e0237aba --- /dev/null +++ b/cinema/cinema-admin/src/main/resources/application.yaml @@ -0,0 +1,15 @@ +spring: + datasource: + url: jdbc:mysql://localhost:3306/cinema + username: user + password: password + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: update + properties: + hibernate: + dialect: org.hibernate.dialect.MySQLDialect + sql: + init: + mode: always \ No newline at end of file diff --git a/cinema/cinema-admin/src/test/java/com/study/cinema/CinemaAdminApplicationTests.java b/cinema/cinema-admin/src/test/java/com/study/cinema/CinemaAdminApplicationTests.java new file mode 100644 index 000000000..d82453db9 --- /dev/null +++ b/cinema/cinema-admin/src/test/java/com/study/cinema/CinemaAdminApplicationTests.java @@ -0,0 +1,13 @@ +package com.study.cinema; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CinemaAdminApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/cinema/cinema-api/build.gradle.kts b/cinema/cinema-api/build.gradle.kts new file mode 100644 index 000000000..f91f00122 --- /dev/null +++ b/cinema/cinema-api/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + kotlin("jvm") + kotlin("plugin.spring") + id("org.springframework.boot") + id("io.spring.dependency-management") +} +dependencies { + implementation(project(":cinema-domain")) + implementation("org.springframework.boot:spring-boot-starter-web") + testImplementation("org.springframework.boot:spring-boot-starter-test") +} diff --git a/cinema/cinema-api/src/main/kotlin/com/study/cinema/CinemaApiApplication.kt b/cinema/cinema-api/src/main/kotlin/com/study/cinema/CinemaApiApplication.kt new file mode 100644 index 000000000..9d1195776 --- /dev/null +++ b/cinema/cinema-api/src/main/kotlin/com/study/cinema/CinemaApiApplication.kt @@ -0,0 +1,11 @@ +package com.study.cinema + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class CinemaApiApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/cinema/cinema-api/src/main/kotlin/com/study/cinema/application/CinemaScheduleFacade.kt b/cinema/cinema-api/src/main/kotlin/com/study/cinema/application/CinemaScheduleFacade.kt new file mode 100644 index 000000000..92c22c38a --- /dev/null +++ b/cinema/cinema-api/src/main/kotlin/com/study/cinema/application/CinemaScheduleFacade.kt @@ -0,0 +1,12 @@ +package com.study.cinema.application + +import com.study.cinema.domain.schedule.MovieScheduleQueryService +import org.springframework.stereotype.Component + +@Component +class CinemaScheduleFacade( + private val movieScheduleQueryService: MovieScheduleQueryService +) { + fun getSchedulesByCinemaId(campaignId: Long) = + movieScheduleQueryService.findByCinemaId(campaignId) +} \ No newline at end of file diff --git a/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Controller.kt b/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Controller.kt new file mode 100644 index 000000000..50b0e958a --- /dev/null +++ b/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Controller.kt @@ -0,0 +1,23 @@ +package com.study.cinema.`interface` + +import com.study.cinema.application.CinemaScheduleFacade +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("api/v1/cinemas/") +class CinemaV1Controller( + private val movieScheduleSearchFacade: CinemaScheduleFacade +) { + + @GetMapping("{cinemaId}/schedules") + fun getSchedulesByCinemaId( + @PathVariable cinemaId: Long + ) = ResponseEntity.ok( + movieScheduleSearchFacade.getSchedulesByCinemaId(cinemaId) + .map { CinemaV1Dto.Response.MovieWithTheaterSchedule(it) } + ) +} \ No newline at end of file diff --git a/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Dto.kt b/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Dto.kt new file mode 100644 index 000000000..7988fed13 --- /dev/null +++ b/cinema/cinema-api/src/main/kotlin/com/study/cinema/interface/CinemaV1Dto.kt @@ -0,0 +1,54 @@ +package com.study.cinema.`interface` + +import com.study.cinema.domain.movie.Genre +import com.study.cinema.domain.movie.MovieInfo +import java.time.LocalDate +import java.time.ZonedDateTime + +class CinemaV1Dto { + class Response { + data class MovieWithTheaterSchedule( + val movieId: Long, + val movieTitle: String, + val movieRating: MovieRating, + val releaseDate: LocalDate, + val thumbnailUrl: String, + val runningTimeMinutes: Int, + val genre: Genre, + val schedules: List + ) { + constructor(movieSchedule: MovieInfo.MovieSchedule) : this( + movieId = movieSchedule.movieId, + movieTitle = movieSchedule.movieTitle, + movieRating = MovieRating.valueOf(movieSchedule.movieRating.name), + releaseDate = movieSchedule.releaseDate, + thumbnailUrl = movieSchedule.thumbnailUrl, + runningTimeMinutes = movieSchedule.runningTimeMinutes, + genre = movieSchedule.genre, + movieSchedule.schedules.map { ScheduleArea(it) } + ) + } + + data class ScheduleArea( + val movieScheduleId: Long, + val theaterTitle: String, + val startAt: ZonedDateTime, + val endAt: ZonedDateTime, + ) { + constructor(theaterSchedule: MovieInfo.TheaterScheduleArea) : this( + movieScheduleId = theaterSchedule.movieScheduleId, + theaterTitle = theaterSchedule.theaterTitle, + startAt = theaterSchedule.startAt, + endAt = theaterSchedule.endAt, + ) + } + } + + enum class MovieRating(val description: String) { + G("전체 관람가"), + PG_13("12세 이상 관람가"), + PG_15("15세 이상 관람가"), + R("청소년 관람불가"), + X("제한 상영가") + } +} \ No newline at end of file diff --git a/cinema/cinema-api/src/main/resources/application.yaml b/cinema/cinema-api/src/main/resources/application.yaml new file mode 100644 index 000000000..8ae85debf --- /dev/null +++ b/cinema/cinema-api/src/main/resources/application.yaml @@ -0,0 +1,19 @@ +spring: + datasource: + url: jdbc:mysql://localhost:3306/cinema + username: cinema + password: cinema + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: none + properties: + hibernate: + dialect: org.hibernate.dialect.MySQLDialect + defer-datasource-initialization: true + sql: + init: + schema-locations: classpath:schema.sql + data-locations: classpath:data.sql + mode: always + diff --git a/cinema/cinema-api/src/main/resources/data.sql b/cinema/cinema-api/src/main/resources/data.sql new file mode 100644 index 000000000..cf562ec6d --- /dev/null +++ b/cinema/cinema-api/src/main/resources/data.sql @@ -0,0 +1,43 @@ +-- 영화관 데이터 삽입 +INSERT INTO cinema.cinema (id, name, address, contact_number) VALUES + (1, '강남 메가박스', '서울 강남구 테헤란로 123', '02-123-4567'); + +-- 영화 데이터 삽입 +INSERT INTO cinema.movie (id, title, genre, movie_rating, release_date, running_time_minutes, thumbnail_url) VALUES + (1, '범죄 도시', 'CRIME', 'R', '2023-05-12', 120, 'https://example.com/images/crime_thumbnail.jpg'), + (2, '로맨틱 가이드', 'ROMANCE', 'PG_13', '2023-06-01', 110, 'https://example.com/images/romance_thumbnail.jpg'), + (3, '호러 나이트', 'HORROR', 'PG_13', '2023-10-15', 100, 'https://example.com/images/horror_thumbnail.jpg'), + (4, 'SF 어드벤처', 'SCI_FI', 'G', '2024-01-01', 140, 'https://example.com/images/scifi_thumbnail.jpg'); + +-- 상영관 데이터 삽입 +INSERT INTO cinema.theater (id, title, cinema_id) VALUES + (1, '1관', 1), + (2, '2관', 1), + (3, '3관', 1), + (4, '4관', 1); + +-- 상영 일정 데이터 삽입 +INSERT INTO cinema.movie_schedule (start_at, end_at, movie_id, theater_id, cinema_id) VALUES +-- 1일차 +('2024-01-01 08:00:00', '2024-01-01 10:00:00', 1, 1, 1), +('2024-01-01 10:30:00', '2024-01-01 12:30:00', 2, 2, 1), +('2024-01-01 13:00:00', '2024-01-01 15:00:00', 3, 3, 1), +('2024-01-01 15:30:00', '2024-01-01 18:00:00', 4, 4, 1), + +-- 2일차 +('2024-01-02 08:00:00', '2024-01-02 10:00:00', 2, 1, 1), +('2024-01-02 10:30:00', '2024-01-02 12:30:00', 3, 2, 1), +('2024-01-02 13:00:00', '2024-01-02 15:00:00', 4, 3, 1), +('2024-01-02 15:30:00', '2024-01-02 18:00:00', 1, 4, 1), + +-- 3일차 +('2024-01-03 08:00:00', '2024-01-03 10:00:00', 3, 1, 1), +('2024-01-03 10:30:00', '2024-01-03 12:30:00', 4, 2, 1), +('2024-01-03 13:00:00', '2024-01-03 15:00:00', 1, 3, 1), +('2024-01-03 15:30:00', '2024-01-03 18:00:00', 2, 4, 1), + +-- 4일차 +('2024-01-04 08:00:00', '2024-01-04 10:00:00', 4, 1, 1), +('2024-01-04 10:30:00', '2024-01-04 12:30:00', 1, 2, 1), +('2024-01-04 13:00:00', '2024-01-04 15:00:00', 2, 3, 1), +('2024-01-04 15:30:00', '2024-01-04 18:00:00', 3, 4, 1); \ No newline at end of file diff --git a/cinema/cinema-api/src/main/resources/schema.sql b/cinema/cinema-api/src/main/resources/schema.sql new file mode 100644 index 000000000..84df9a9b0 --- /dev/null +++ b/cinema/cinema-api/src/main/resources/schema.sql @@ -0,0 +1,43 @@ +DROP TABLE IF EXISTS cinema.movie_schedule; +DROP TABLE IF EXISTS cinema.theater; +DROP TABLE IF EXISTS cinema.movie; +DROP TABLE IF EXISTS cinema.cinema; + +CREATE TABLE cinema.cinema ( + id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + address VARCHAR(255) NOT NULL, + contact_number VARCHAR(255) NOT NULL +); + +CREATE TABLE cinema.movie ( + id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + genre VARCHAR(50) NOT NULL, + movie_rating VARCHAR(20) NOT NULL, + release_date DATE NOT NULL, + running_time_minutes INT NOT NULL, + thumbnail_url VARCHAR(255) NOT NULL +); + +CREATE TABLE cinema.theater ( + id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + cinema_id BIGINT UNSIGNED NOT NULL +); + +CREATE TABLE cinema.movie_schedule ( + id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + start_at DATETIME NOT NULL, + end_at DATETIME NOT NULL, + movie_id BIGINT UNSIGNED NOT NULL, + theater_id BIGINT UNSIGNED NOT NULL, + cinema_id BIGINT UNSIGNED NOT NULL +); + +CREATE TABLE cinema.seat( + id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + theater_id BIGINT UNSIGNED NOT NULL, + position_row VARCHAR(255) NOT NULL, + position_column VARCHAR(255) NOT NULL +) \ No newline at end of file diff --git a/cinema/cinema-api/src/test/kotlin/com/study/cinema/CinemaApiApplicationTests.kt b/cinema/cinema-api/src/test/kotlin/com/study/cinema/CinemaApiApplicationTests.kt new file mode 100644 index 000000000..bbb736a45 --- /dev/null +++ b/cinema/cinema-api/src/test/kotlin/com/study/cinema/CinemaApiApplicationTests.kt @@ -0,0 +1,13 @@ +package com.study.cinema + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class CinemaApiApplicationTests { + + @Test + fun contextLoads() { + } + +} diff --git a/cinema/cinema-domain/build.gradle.kts b/cinema/cinema-domain/build.gradle.kts new file mode 100644 index 000000000..a979af4dd --- /dev/null +++ b/cinema/cinema-domain/build.gradle.kts @@ -0,0 +1,11 @@ +apply { + plugin("org.jetbrains.kotlin.plugin.jpa") +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + runtimeOnly("com.mysql:mysql-connector-j") + implementation(group = "com.querydsl", name = "querydsl-jpa", classifier = "jakarta") + kapt(group ="com.querydsl", name = "querydsl-apt", classifier = "jakarta") + +} diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/cinema/Cinema.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/cinema/Cinema.kt new file mode 100644 index 000000000..709654306 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/cinema/Cinema.kt @@ -0,0 +1,33 @@ +package com.study.cinema.domain.cinema + +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.Table +import org.hibernate.annotations.Comment + +@Entity +@Table(name = "cinema") +class Cinema( + name: String, + address: String, + contactNumber: String +) { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 + + @Comment("영화관 이름") + var name: String = name + protected set + + @Comment("영화관 주소") + var address: String = address + protected set + + @Comment("영화관 연락처") + var contactNumber: String = contactNumber + protected set +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Genre.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Genre.kt new file mode 100644 index 000000000..8ab3e64a5 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Genre.kt @@ -0,0 +1,14 @@ +package com.study.cinema.domain.movie + +enum class Genre(val description: String) { + DRAMA("드라마"), + COMEDY("코미디"), + ACTION("액션"), + HORROR("공포"), + SCI_FI("공상과학"), + ROMANCE("로맨스"), + THRILLER("스릴러"), + FANTASY("판타지"), + ADVENTURE("모험"), + CRIME("범죄") +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Movie.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Movie.kt new file mode 100644 index 000000000..0c500769b --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/Movie.kt @@ -0,0 +1,55 @@ +package com.study.cinema.domain.movie + +import jakarta.persistence.Column +import jakarta.persistence.EnumType +import jakarta.persistence.Enumerated +import org.hibernate.annotations.Comment +import java.time.LocalDate + +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id + +@Entity +class Movie( + title: String, + genre: Genre, + movieRating: MovieRating, + releaseDate: LocalDate, + runningTimeMinutes: Int, + posterUrl: String, +) { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 + + @Comment("제목") + var title: String = title + protected set + + @Comment("장르") + @Enumerated(EnumType.STRING) + @Column(length = 50) + var genre: Genre = genre + protected set + + @Comment("영상물 등급") + @Enumerated(EnumType.STRING) + @Column(length = 50) + var movieRating: MovieRating = movieRating + protected set + + @Comment("개봉일") + var releaseDate: LocalDate = releaseDate + protected set + + @Comment("러닝 타임 (분)") + var runningTimeMinutes: Int = runningTimeMinutes + protected set + + @Comment("포스터 URL") + var thumbnailUrl: String = posterUrl + protected set +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieInfo.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieInfo.kt new file mode 100644 index 000000000..34d5b160f --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieInfo.kt @@ -0,0 +1,49 @@ +package com.study.cinema.domain.movie + +import java.time.LocalDate +import java.time.ZonedDateTime + +class MovieInfo { + + data class MovieSchedule ( + val movieId: Long, + val movieTitle: String, + val movieRating: MovieRating, + val releaseDate: LocalDate, + val thumbnailUrl: String, + val runningTimeMinutes: Int, + val genre: Genre, + val schedules: List + ) { + constructor( + movie: Movie, + movieSchedules: List + ) : this( + movieId = movie.id, + movieTitle = movie.title, + movieRating = movie.movieRating, + releaseDate = movie.releaseDate, + thumbnailUrl = movie.thumbnailUrl, + runningTimeMinutes = movie.runningTimeMinutes, + genre = movie.genre, + schedules = movieSchedules.map { TheaterScheduleArea(it) } + ) + } + + data class TheaterScheduleArea ( + val movieScheduleId: Long, + val theaterTitle: String, + val startAt: ZonedDateTime, + val endAt: ZonedDateTime, + ) { + constructor(movieSchedule: com.study.cinema.domain.schedule.MovieSchedule): this( + movieScheduleId = movieSchedule.id, + theaterTitle = movieSchedule.theater.title, + startAt = movieSchedule.startAt, + endAt = movieSchedule.endAt, + ) + } + + + +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieRating.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieRating.kt new file mode 100644 index 000000000..37562515e --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/movie/MovieRating.kt @@ -0,0 +1,9 @@ +package com.study.cinema.domain.movie + +enum class MovieRating(val description: String) { + G("전체 관람가"), + PG_13("12세 이상 관람가"), + PG_15("15세 이상 관람가"), + R("청소년 관람불가"), + X("제한 상영가") +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieSchedule.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieSchedule.kt new file mode 100644 index 000000000..771a8dba4 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieSchedule.kt @@ -0,0 +1,49 @@ +package com.study.cinema.domain.schedule + +import com.study.cinema.domain.cinema.Cinema +import com.study.cinema.domain.movie.Movie +import com.study.cinema.domain.theater.Theater +import jakarta.persistence.Entity +import jakarta.persistence.FetchType +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.JoinColumn +import jakarta.persistence.ManyToOne +import jakarta.persistence.Table +import org.hibernate.annotations.Comment +import java.time.ZonedDateTime + +@Entity +@Table(name = "movie_schedule") +class MovieSchedule( + startAt: ZonedDateTime, + endAt: ZonedDateTime, + movie: Movie, + theater: Theater +) { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 + + @Comment("상영 시작 시간") + var startAt: ZonedDateTime = startAt + protected set + + @Comment("상영 종료 시간") + var endAt: ZonedDateTime = endAt + protected set + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "movie_id") + val movie: Movie = movie + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "theater_id") + val theater: Theater = theater + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "cinema_id") + val cinema: Cinema = theater.cinema +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieScheduleQueryService.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieScheduleQueryService.kt new file mode 100644 index 000000000..a3c747079 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/schedule/MovieScheduleQueryService.kt @@ -0,0 +1,23 @@ +package com.study.cinema.domain.schedule + +import com.study.cinema.domain.movie.MovieInfo +import com.study.cinema.infra.jpa.movie.MovieScheduleRepository +import jakarta.transaction.Transactional +import org.springframework.stereotype.Service + +@Service +@Transactional +class MovieScheduleQueryService( + private val movieScheduleRepository: MovieScheduleRepository, +) { + fun findByCinemaId(cinemaId: Long): List { + val schedules = movieScheduleRepository.findByCinemaId(cinemaId) + return schedules.groupBy { it.movie.id } + .map { it.value } + .map { + MovieInfo.MovieSchedule(it.first().movie, it.sortedBy { it.startAt }) + } + .sortedByDescending { it.releaseDate } + } + +} diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/seat/Seat.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/seat/Seat.kt new file mode 100644 index 000000000..5e541837f --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/seat/Seat.kt @@ -0,0 +1,16 @@ +package com.study.cinema.domain.seat + +import com.study.cinema.domain.theater.Theater +import jakarta.persistence.* + +@Entity +class Seat( + @ManyToOne(fetch = FetchType.LAZY) + val theater: Theater, + val positionRow: String, + val positionColumn: String, +) { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id = 0L +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/theater/Theater.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/theater/Theater.kt new file mode 100644 index 000000000..4c123f438 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/domain/theater/Theater.kt @@ -0,0 +1,32 @@ +package com.study.cinema.domain.theater + +import com.study.cinema.domain.cinema.Cinema +import jakarta.persistence.Entity +import jakarta.persistence.FetchType +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.JoinColumn +import jakarta.persistence.ManyToOne +import jakarta.persistence.Table +import org.hibernate.annotations.Comment + +@Entity +@Table +class Theater( + title: String, + cinema: Cinema, +) { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 + + @Comment("상영관 이름") + var title: String = title + protected set + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "cinema_id") + val cinema: Cinema = cinema +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/QueryDslConfig.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/QueryDslConfig.kt new file mode 100644 index 000000000..f33376ae9 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/QueryDslConfig.kt @@ -0,0 +1,21 @@ +package com.study.cinema.infra.jpa + +import com.querydsl.jpa.JPQLTemplates +import com.querydsl.jpa.impl.JPAQueryFactory +import jakarta.persistence.EntityManager +import jakarta.persistence.PersistenceContext +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + + +@Configuration +class QueryDslConfig( + @PersistenceContext + private val em: EntityManager +) { + + @Bean + fun jpaQueryFactory(): JPAQueryFactory { + return JPAQueryFactory(JPQLTemplates.DEFAULT, em) + } +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepository.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepository.kt new file mode 100644 index 000000000..ce5baa6f9 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepository.kt @@ -0,0 +1,6 @@ +package com.study.cinema.infra.jpa.movie + +import com.study.cinema.domain.schedule.MovieSchedule +import org.springframework.data.jpa.repository.JpaRepository + +interface MovieScheduleRepository : JpaRepository, MovieScheduleRepositoryCustom \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustom.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustom.kt new file mode 100644 index 000000000..76d495761 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustom.kt @@ -0,0 +1,7 @@ +package com.study.cinema.infra.jpa.movie + +import com.study.cinema.domain.schedule.MovieSchedule + +interface MovieScheduleRepositoryCustom { + fun findByCinemaId(cinemaId: Long): List +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustomImpl.kt b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustomImpl.kt new file mode 100644 index 000000000..853a977e0 --- /dev/null +++ b/cinema/cinema-domain/src/main/kotlin/com/study/cinema/infra/jpa/movie/MovieScheduleRepositoryCustomImpl.kt @@ -0,0 +1,27 @@ +package com.study.cinema.infra.jpa.movie + +import com.study.cinema.domain.movie.QMovie +import com.study.cinema.domain.schedule.MovieSchedule +import com.study.cinema.domain.schedule.QMovieSchedule +import com.study.cinema.domain.theater.QTheater +import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport + +class MovieScheduleRepositoryCustomImpl : QuerydslRepositorySupport(MovieSchedule::class.java), + MovieScheduleRepositoryCustom { + + override fun findByCinemaId(cinemaId: Long): List { + return from(qMovieSchedule) + .join(qMovieSchedule.movie, qMovie).fetchJoin() + .join(qMovieSchedule.theater, qTheater).fetchJoin() + .where( + qMovieSchedule.cinema.id.eq(cinemaId) + ) + .fetch() + } + + companion object { + val qMovieSchedule: QMovieSchedule = QMovieSchedule.movieSchedule + val qMovie: QMovie = QMovie.movie + val qTheater: QTheater = QTheater.theater + } +} \ No newline at end of file diff --git a/cinema/cinema-domain/src/main/resources/application.properties b/cinema/cinema-domain/src/main/resources/application.properties new file mode 100644 index 000000000..ad6ffd80e --- /dev/null +++ b/cinema/cinema-domain/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=cinema-domain diff --git a/cinema/cinema-domain/src/test/kotlin/com/study/cinema/CinemaDomainApplicationTests.kt b/cinema/cinema-domain/src/test/kotlin/com/study/cinema/CinemaDomainApplicationTests.kt new file mode 100644 index 000000000..d4aeb2429 --- /dev/null +++ b/cinema/cinema-domain/src/test/kotlin/com/study/cinema/CinemaDomainApplicationTests.kt @@ -0,0 +1,13 @@ +package com.study.cinema + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class CinemaDomainApplicationTests { + + @Test + fun contextLoads() { + } + +} diff --git a/cinema/compose.yaml b/cinema/compose.yaml new file mode 100644 index 000000000..869f79a2a --- /dev/null +++ b/cinema/compose.yaml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + mysql: + image: mysql:8.0 + container_name: mysql-container + restart: always + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: cinema + MYSQL_USER: cinema + MYSQL_PASSWORD: cinema + volumes: + - mysql_data:/var/lib/mysql + +volumes: + mysql_data: \ No newline at end of file diff --git a/cinema/gradle/wrapper/gradle-wrapper.jar b/cinema/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..a4b76b953 Binary files /dev/null and b/cinema/gradle/wrapper/gradle-wrapper.jar differ diff --git a/cinema/gradle/wrapper/gradle-wrapper.properties b/cinema/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..e2847c820 --- /dev/null +++ b/cinema/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/cinema/gradlew b/cinema/gradlew new file mode 100644 index 000000000..f5feea6d6 --- /dev/null +++ b/cinema/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/cinema/gradlew.bat b/cinema/gradlew.bat new file mode 100644 index 000000000..9d21a2183 --- /dev/null +++ b/cinema/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/cinema/http/movie.http b/cinema/http/movie.http new file mode 100644 index 000000000..cd507e615 --- /dev/null +++ b/cinema/http/movie.http @@ -0,0 +1,2 @@ +### +GET http://localhost:8080/api/v1/cinemas/1/schedules \ No newline at end of file diff --git a/cinema/settings.gradle.kts b/cinema/settings.gradle.kts new file mode 100644 index 000000000..da8ed8201 --- /dev/null +++ b/cinema/settings.gradle.kts @@ -0,0 +1,7 @@ +rootProject.name = "cinema" + +include( + "cinema-admin", + "cinema-domain", + "cinema-api", +) \ No newline at end of file