Added main structure
This commit is contained in:
19
api/Dockerfile
Normal file
19
api/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# -------- Stage 1: Build the jar using Gradle --------
|
||||
FROM gradle:9.2-jdk21 AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY settings.gradle.kts build.gradle.kts ./
|
||||
COPY gradle ./gradle
|
||||
|
||||
COPY src ./src
|
||||
|
||||
RUN gradle clean bootJar --no-daemon
|
||||
|
||||
FROM eclipse-temurin:21-jdk-alpine
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /app/build/libs/*.jar app.jar
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
@@ -36,6 +36,7 @@ dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-elasticsearch")
|
||||
implementation("org.springframework.boot:spring-boot-starter-mongodb")
|
||||
implementation("org.springframework.boot:spring-boot-starter-opentelemetry")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
|
||||
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
developmentOnly("org.springframework.boot:spring-boot-docker-compose")
|
||||
|
||||
@@ -30,11 +30,27 @@ services:
|
||||
- "8300:9090"
|
||||
volumes:
|
||||
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
|
||||
|
||||
mongodb:
|
||||
image: 'mongo:latest'
|
||||
image: mongo:latest
|
||||
environment:
|
||||
- 'MONGO_INITDB_DATABASE=mydatabase'
|
||||
- 'MONGO_INITDB_ROOT_PASSWORD=secret'
|
||||
- 'MONGO_INITDB_ROOT_USERNAME=root'
|
||||
- MONGO_INITDB_DATABASE=my-database
|
||||
- MONGO_INITDB_ROOT_PASSWORD=secret
|
||||
- MONGO_INITDB_ROOT_USERNAME=root
|
||||
ports:
|
||||
- '8400:27017'
|
||||
- "8400:27017"
|
||||
volumes:
|
||||
- ./mongo-data:/data/db
|
||||
|
||||
#mongo-express:
|
||||
# image: mongo-express:latest
|
||||
# depends_on:
|
||||
# - mongodb
|
||||
# ports:
|
||||
# - "8401:8081"
|
||||
# environment:
|
||||
# - ME_CONFIG_MONGODB_SERVER=mongodb
|
||||
# - ME_CONFIG_MONGODB_PORT=27017
|
||||
# - ME_CONFIG_MONGODB_ADMINUSERNAME=root
|
||||
# - ME_CONFIG_MONGODB_ADMINPASSWORD=secret
|
||||
# - ME_CONFIG_MONGODB_AUTH_DATABASE=admin
|
||||
@@ -1,6 +1,5 @@
|
||||
package be.naaturel.boardmateapi.configurations;
|
||||
|
||||
import be.naaturel.boardmateapi.Interceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package be.naaturel.boardmateapi;
|
||||
package be.naaturel.boardmateapi.configurations;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -0,0 +1,26 @@
|
||||
package be.naaturel.boardmateapi.controllers;
|
||||
|
||||
import org.apache.coyote.Response;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class PartyController {
|
||||
|
||||
|
||||
public PartyController(){
|
||||
|
||||
}
|
||||
|
||||
public ResponseEntity<?> CreateParty(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResponseEntity<?> RetrieveParty(int id){
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResponseEntity<?> AddMove(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package be.naaturel.boardmateapi.models;
|
||||
|
||||
public class Coordinate {
|
||||
|
||||
private int row;
|
||||
private String file;
|
||||
|
||||
public Coordinate(int row, String file){
|
||||
this.row = row;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("%s%d", file, row);
|
||||
}
|
||||
|
||||
}
|
||||
13
api/src/main/java/be/naaturel/boardmateapi/models/Move.java
Normal file
13
api/src/main/java/be/naaturel/boardmateapi/models/Move.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package be.naaturel.boardmateapi.models;
|
||||
|
||||
public class Move {
|
||||
|
||||
private Piece piece;
|
||||
private Coordinate coordinate;
|
||||
|
||||
public Move(Piece piece, Coordinate coordinate){
|
||||
this.piece = piece;
|
||||
this.coordinate = coordinate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package be.naaturel.boardmateapi.models;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Party {
|
||||
|
||||
private List<Move> moves;
|
||||
|
||||
}
|
||||
11
api/src/main/java/be/naaturel/boardmateapi/models/Piece.java
Normal file
11
api/src/main/java/be/naaturel/boardmateapi/models/Piece.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package be.naaturel.boardmateapi.models;
|
||||
|
||||
public class Piece {
|
||||
|
||||
|
||||
|
||||
public Piece(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package be.naaturel.boardmateapi.repository;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = "parties")
|
||||
public class PartyDto {
|
||||
@Id
|
||||
private String id;
|
||||
private String[] moves;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package be.naaturel.boardmateapi.repository;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface PartyRepo extends MongoRepository<Party, String> {
|
||||
Optional<Party> findById(String id);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package be.naaturel.boardmateapi.repository.test;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
|
||||
public interface CustomPartyRepo {
|
||||
public Party find(String id);
|
||||
public String create();
|
||||
public String registerMove();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package be.naaturel.boardmateapi.repository.test;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
|
||||
public class CustomPartyRepoImpl implements CustomPartyRepo{
|
||||
|
||||
@Override
|
||||
public Party find(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String create() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String registerMove() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package be.naaturel.boardmateapi.services;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
import be.naaturel.boardmateapi.repository.test.CustomPartyRepoImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PartyService {
|
||||
|
||||
private final CustomPartyRepoImpl repo;
|
||||
|
||||
public PartyService(CustomPartyRepoImpl repo){
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
public Party retrieveParty(String id){
|
||||
return null;
|
||||
}
|
||||
|
||||
public String create(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public String addMove(){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user