diff --git a/.gitignore b/.gitignore
index 667aaef..2855b1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@ build/
### VS Code ###
.vscode/
+/generated/
+/.mvn/
diff --git a/docker-build.sh b/docker-build.sh
new file mode 100644
index 0000000..ea2726b
--- /dev/null
+++ b/docker-build.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Ordner zum Speichern der Images
+SAVE_DIR="./docker_images"
+
+# Erstelle Ordner, falls nicht vorhanden
+mkdir -p "$SAVE_DIR"
+
+# Build aller Images ohne Cache
+docker compose build --no-cache
+
+# Liste der Images, die gebaut werden (muss zu deinen image-Namen passen)
+IMAGES=(
+ "backend:latest"
+)
+
+# Images speichern
+for IMAGE in "${IMAGES[@]}"
+do
+ # Dateiname: ersetze : mit _ um Probleme zu vermeiden
+ FILE_NAME=$(echo $IMAGE | tr ':' '_').tar
+
+ echo "Speichere Image $IMAGE als $SAVE_DIR/$FILE_NAME"
+ docker save "$IMAGE" -o "$SAVE_DIR/$FILE_NAME"
+done
+
+echo "Fertig! Alle Images sind in $SAVE_DIR gespeichert."
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..a113298
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,28 @@
+version: '3.8'
+
+services:
+ app:
+ build:
+ context: ./backend
+ dockerfile: Dockerfile
+ image: sumoc-backend:latest
+ container_name: sumoc_backend
+ ports:
+ - "8080:8080"
+ depends_on:
+ - db
+ environment:
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/postgres?autocommit=false
+ - SPRING_DATASOURCE_USERNAME=postgres
+ - SPRING_DATASOURCE_PASSWORD=admin
+ - SPRING_JPA_HIBERNATE_DDL_AUTO=update
+
+ db:
+ image: postgres:16.2-alpine
+ container_name: sumoc_db
+ environment:
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=admin
+ - POSTGRES_DB=postgres
+ ports:
+ - "3333:5432"
diff --git a/docker-load.sh b/docker-load.sh
new file mode 100644
index 0000000..1de4ca9
--- /dev/null
+++ b/docker-load.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Ordner mit den gespeicherten Images
+SAVE_DIR="./docker_images"
+
+# Liste der Image-Dateien (Namen anpassen, falls nötig)
+IMAGE_FILES=(
+ "backend_latest.tar"
+)
+
+for FILE in "${IMAGE_FILES[@]}"
+do
+ FILE_PATH="$SAVE_DIR/$FILE"
+ if [ -f "$FILE_PATH" ]; then
+ echo "Lade Image von $FILE_PATH"
+ docker load -i "$FILE_PATH"
+ else
+ echo "Datei nicht gefunden: $FILE_PATH"
+ fi
+done
+
+echo "Fertig! Alle Images wurden geladen."
diff --git a/pom.xml b/pom.xml
index 0c26b50..2b98823 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,7 @@
org.springframework.boot
spring-boot-starter-actuator
+
@@ -115,7 +116,85 @@
+
+
+
+ org.openapitools
+ openapi-generator-maven-plugin
+ 7.8.0
+
+
+ generate-android-client
+ none
+
+ generate
+
+
+ http://localhost:8080/v3/api-docs.yaml
+ kotlin
+
+
+
+
+
+ generate-ios-client
+ none
+
+ generate
+
+
+ http://localhost:8080/v3/api-docs.yaml
+ swift5
+
+
+
+
+
+
+
+ generate-clients
+
+ false
+
+
+
+
+ org.openapitools
+ openapi-generator-maven-plugin
+ 7.8.0
+
+
+ generate-android-client
+ generate-sources
+
+ generate
+
+
+ http://localhost:8080/v3/api-docs.yaml
+ kotlin
+
+
+
+
+ generate-ios-client
+ generate-sources
+
+ generate
+
+
+ http://localhost:8080/v3/api-docs.yaml
+ swift5
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/SuMoC/backend/models/Friendship.java b/src/main/java/SuMoC/backend/models/Friendship.java
new file mode 100644
index 0000000..d2ae290
--- /dev/null
+++ b/src/main/java/SuMoC/backend/models/Friendship.java
@@ -0,0 +1,17 @@
+package SuMoC.backend.models;
+
+import jakarta.persistence.*;
+
+@Entity
+@Table(name = "friendships")
+public class Friendship {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @Column(nullable = false)
+ private Long userId1;
+
+ @Column(nullable = false)
+ private Long userId2;
+}
diff --git a/src/main/java/SuMoC/backend/models/Modality.java b/src/main/java/SuMoC/backend/models/Modality.java
new file mode 100644
index 0000000..fdafde1
--- /dev/null
+++ b/src/main/java/SuMoC/backend/models/Modality.java
@@ -0,0 +1,12 @@
+package SuMoC.backend.models;
+
+public enum Modality {
+ IDLE,
+ WALKING,
+ BIKE,
+ ESCOOTER,
+ BUS,
+ TRAM,
+ TRAIN,
+ CAR
+}
diff --git a/src/main/java/SuMoC/backend/models/RoleName.java b/src/main/java/SuMoC/backend/models/RoleName.java
index d47bb34..280a4e2 100644
--- a/src/main/java/SuMoC/backend/models/RoleName.java
+++ b/src/main/java/SuMoC/backend/models/RoleName.java
@@ -2,7 +2,5 @@ package SuMoC.backend.models;
public enum RoleName {
USER,
- ADMIN,
- MODERATOR,
- SENSOR
+ ADMIN
}
\ No newline at end of file
diff --git a/src/main/java/SuMoC/backend/models/Trip.java b/src/main/java/SuMoC/backend/models/Trip.java
new file mode 100644
index 0000000..7672668
--- /dev/null
+++ b/src/main/java/SuMoC/backend/models/Trip.java
@@ -0,0 +1,39 @@
+package SuMoC.backend.models;
+
+
+import jakarta.persistence.*;
+
+import java.time.LocalDateTime;
+
+@Entity
+@Table(name = "trips")
+public class Trip {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @Column(nullable = false)
+ private Long startPlace;
+
+ @Column(nullable = false)
+ private Long endPlace;
+
+ @Column(nullable = false)
+ private LocalDateTime startTime;
+
+ @Column(nullable = false)
+ private LocalDateTime endTime;
+
+ /**
+ * Mobilityscore for the trip. TODO determine if this needs an own data type
+ */
+ @Column(nullable = false)
+ private float score;
+
+ @Column(nullable = true)
+ private float cost;
+
+ @Column()
+ private Set segments;
+
+}
diff --git a/src/main/java/SuMoC/backend/models/TripSegment.java b/src/main/java/SuMoC/backend/models/TripSegment.java
new file mode 100644
index 0000000..9413c97
--- /dev/null
+++ b/src/main/java/SuMoC/backend/models/TripSegment.java
@@ -0,0 +1,31 @@
+package SuMoC.backend.models;
+
+
+import jakarta.persistence.*;
+
+import java.time.LocalDateTime;
+
+@Entity
+@Table(name = "trip_segments")
+public class TripSegment {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @Column(nullable = false)
+ private Long TripId;
+
+ @Column(nullable = false)
+ private Modality modality;
+
+ @Column(nullable = false)
+ private LocalDateTime startTime;
+
+ /**
+ * Distance of the segment in meters.
+ */
+ @Column(nullable = false)
+ private Long distance;
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/SuMoC/backend/models/User.java b/src/main/java/SuMoC/backend/models/User.java
index 3c2869c..8eae55e 100644
--- a/src/main/java/SuMoC/backend/models/User.java
+++ b/src/main/java/SuMoC/backend/models/User.java
@@ -10,15 +10,39 @@ public class User {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
+ /**
+ * The public name of the user, displayed in public leaderboards etc.
+ */
@Column(unique = true, nullable = false)
- private String username;
+ private String publicName;
+
+ /**
+ * The private name of the user, used in private leaderboards, shown to friends etc.
+ */
+ @Column(nullable = false)
+ private String privateName;
@Column(unique = true, nullable = false)
private String email;
+
@Column(nullable = false)
private String password;
+ @Column(nullable = false)
+ private VisibilityPrivacy visibilityPrivacy;
+
+ @Column(nullable = false)
+ private String friendCode;
+
+ // TODO: TripList
+ @JoinColumn(nullable = true)
+ @OneToMany(cascade = CascadeType.ALL)
+ private Set trips;
+
+ // TODO : friendList
+ private Set friendships;
+
@ElementCollection(targetClass = RoleName.class, fetch = FetchType.EAGER)
@Enumerated(EnumType.STRING)
@CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"))
diff --git a/src/main/java/SuMoC/backend/models/VisibilityPrivacy.java b/src/main/java/SuMoC/backend/models/VisibilityPrivacy.java
new file mode 100644
index 0000000..d89fa72
--- /dev/null
+++ b/src/main/java/SuMoC/backend/models/VisibilityPrivacy.java
@@ -0,0 +1,10 @@
+package SuMoC.backend.models;
+
+/**
+ * Privacy enum, representing different levels of visibility for the user in leaderboards etc.
+ */
+public enum VisibilityPrivacy {
+ NONE,
+ FRIENDS_ONLY,
+ PUBLIC
+}
diff --git a/src/main/resources/api-docs.yaml b/src/main/resources/api-docs.yaml
new file mode 100644
index 0000000..f984289
--- /dev/null
+++ b/src/main/resources/api-docs.yaml
@@ -0,0 +1,106 @@
+openapi: 3.1.0
+info:
+ title: SuMoC API
+ description: API-Dokumentation für SuMoC
+ version: "1.0"
+servers:
+- url: http://localhost:8080
+ description: Generated server url
+security:
+- bearerAuth: []
+paths:
+ /auth/user/registration:
+ post:
+ tags:
+ - user-authentication-controller
+ summary: Registriert einen neuen Benutzer
+ description: Erstellt einen neuen Benutzer und gibt die Benutzerdaten zurück
+ operationId: registerUser
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/UserRegistrationDTO"
+ required: true
+ responses:
+ "200":
+ description: Benutzer erfolgreich registriert
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/LoginResponseDTO"
+ "400":
+ description: Ungültige Eingabedaten
+ content:
+ application/json: {}
+ /auth/user/login:
+ post:
+ tags:
+ - user-authentication-controller
+ summary: Authentifiziert einen Benutzer
+ description: Prüft den Benutzernamen und das Passwort und gibt ein JWT zurück
+ operationId: login
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/UserAuthenticationPairDTO"
+ required: true
+ responses:
+ "200":
+ description: Erfolgreiche Anmeldung
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/LoginResponseDTO"
+ "401":
+ description: Ungültiger Benutzername oder Passwort
+ content:
+ application/json: {}
+components:
+ schemas:
+ UserRegistrationDTO:
+ type: object
+ properties:
+ username:
+ type: string
+ email:
+ type: string
+ password:
+ type: string
+ LoginResponseDTO:
+ type: object
+ properties:
+ userDTO:
+ $ref: "#/components/schemas/UserDTO"
+ jwt:
+ type: string
+ UserDTO:
+ type: object
+ properties:
+ username:
+ type: string
+ authorities:
+ type: array
+ items:
+ type: string
+ enum:
+ - USER
+ - ADMIN
+ uniqueItems: true
+ id:
+ type: integer
+ format: int64
+ UserAuthenticationPairDTO:
+ type: object
+ properties:
+ email:
+ type: string
+ password:
+ type: string
+ securitySchemes:
+ bearerAuth:
+ type: http
+ name: bearerAuth
+ scheme: bearer
+ bearerFormat: JWT