Some Data Classes added
This commit is contained in:
parent
650ec45a86
commit
932018f2af
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.env
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
||||
services:
|
||||
# spring-boot-kotlin-app:
|
||||
# image: 'spring-boot-kotlin-app:latest' # Specifies the Docker image for the Spring Boot application
|
||||
# build:
|
||||
# context: . # Specifies the build context, which is the current directory
|
||||
# container_name: spring-boot-kotlin-app # Names the container 'spring-boot-kotlin-app'
|
||||
# depends_on:
|
||||
# - db # Ensures that the 'db' service starts before the 'spring-boot-kotlin-app' service
|
||||
# environment:
|
||||
# - SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL}
|
||||
# - SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
|
||||
# - SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
|
||||
# - SPRING_JPA_HIBERNATE_DDL_AUTO=update # Configures Hibernate to update the database schema
|
||||
# ports:
|
||||
# - "8456:8456"
|
||||
# networks:
|
||||
# - app-network
|
||||
|
||||
db:
|
||||
image: postgres:latest
|
||||
container_name: db
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data # Mounts a volume to persist PostgreSQL data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
volumes:
|
||||
postgres_data: # Defines a named volume for PostgreSQL data persistence
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
17
src/main/kotlin/de/tobjend/strategy/model/Game.kt
Normal file
17
src/main/kotlin/de/tobjend/strategy/model/Game.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package de.tobjend.strategy.model
|
||||
|
||||
import jakarta.persistence.*
|
||||
|
||||
@Entity
|
||||
@Table(name = "games")
|
||||
data class Game(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val id: Long = 0,
|
||||
|
||||
@Column(name = "name", nullable = false)
|
||||
val name: String,
|
||||
|
||||
@OneToMany(mappedBy = "game", cascade = [CascadeType.ALL], fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
val players: MutableList<Player> = mutableListOf()
|
||||
)
|
||||
5
src/main/kotlin/de/tobjend/strategy/model/Player.kt
Normal file
5
src/main/kotlin/de/tobjend/strategy/model/Player.kt
Normal file
@ -0,0 +1,5 @@
|
||||
package de.tobjend.strategy.model
|
||||
|
||||
data class Players(
|
||||
val players: List<Player>
|
||||
)
|
||||
21
src/main/kotlin/de/tobjend/strategy/model/Players.kt
Normal file
21
src/main/kotlin/de/tobjend/strategy/model/Players.kt
Normal file
@ -0,0 +1,21 @@
|
||||
package de.tobjend.strategy.model
|
||||
|
||||
import jakarta.persistence.*
|
||||
|
||||
@Entity
|
||||
@Table(name = "players")
|
||||
data class Player(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val id: Long = 0,
|
||||
|
||||
@Column(name = "name", nullable = false)
|
||||
val name: String,
|
||||
|
||||
@Column(name = "position", nullable = false)
|
||||
val position: String,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "game_id")
|
||||
var game: Game? = null
|
||||
)
|
||||
19
src/main/kotlin/de/tobjend/strategy/model/Strategy.kt
Normal file
19
src/main/kotlin/de/tobjend/strategy/model/Strategy.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package de.tobjend.strategy.model
|
||||
|
||||
import jakarta.persistence.*
|
||||
|
||||
@Entity(name = "strategies")
|
||||
data class Strategy(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val id: Long = 0,
|
||||
|
||||
@Column(name = "name", nullable = false)
|
||||
val name: String,
|
||||
|
||||
@Column(name = "description", nullable = true)
|
||||
val description: String?,
|
||||
|
||||
@Column(name = "effectiveness")
|
||||
val effectiveness: Double
|
||||
)
|
||||
@ -1 +1,6 @@
|
||||
spring.application.name=strategy
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/strategy
|
||||
spring.datasource.username=tobi
|
||||
spring.datasource.password=risICE3
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user