Some Data Classes added

This commit is contained in:
Tobias J. Endres 2025-04-27 19:11:13 +02:00
parent 650ec45a86
commit 932018f2af
7 changed files with 106 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
.gradle .gradle
build/ build/
!gradle/wrapper/gradle-wrapper.jar !gradle/wrapper/gradle-wrapper.jar

38
docker-compose.yml Normal file
View 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

View 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()
)

View File

@ -0,0 +1,5 @@
package de.tobjend.strategy.model
data class Players(
val players: List<Player>
)

View 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
)

View 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
)

View File

@ -1 +1,6 @@
spring.application.name=strategy 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