Add some structure
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package be.naaturel.boardmateapi.configurations;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
}
|
||||
@@ -1,26 +1,59 @@
|
||||
package be.naaturel.boardmateapi.controllers;
|
||||
|
||||
import org.apache.coyote.Response;
|
||||
import be.naaturel.boardmateapi.models.Move;
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
import be.naaturel.boardmateapi.services.PartyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
public class PartyController {
|
||||
|
||||
private final PartyService service;
|
||||
|
||||
public PartyController(){
|
||||
|
||||
@Autowired
|
||||
public PartyController(PartyService service){
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public ResponseEntity<?> CreateParty(){
|
||||
return null;
|
||||
@GetMapping("/party/{id}")
|
||||
public ResponseEntity<?> RetrieveParty(@PathVariable String id){
|
||||
try{
|
||||
service.retrieveParty(id);
|
||||
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.build();
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<?> RetrieveParty(int id){
|
||||
return null;
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> CreateParty(@RequestBody Party party){
|
||||
try{
|
||||
service.create();
|
||||
|
||||
return ResponseEntity.
|
||||
status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.build();
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<?> AddMove(){
|
||||
return null;
|
||||
@PostMapping("/moves/add")
|
||||
public ResponseEntity<?> AddMove(@RequestBody Move move){
|
||||
try{
|
||||
service.addMove();
|
||||
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.OK)
|
||||
.build();
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
package be.naaturel.boardmateapi.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Party {
|
||||
|
||||
private List<Move> moves;
|
||||
private final String whiteName;
|
||||
private final String blackName;
|
||||
private final int timeControl;
|
||||
private final int increment;
|
||||
private final List<Move> moves;
|
||||
|
||||
public Party(String whiteName, String blackName, int timeControl, int increment){
|
||||
this.whiteName = whiteName;
|
||||
this.blackName = blackName;
|
||||
this.timeControl = timeControl;
|
||||
this.increment = increment;
|
||||
this.moves = new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package be.naaturel.boardmateapi.repository.test;
|
||||
package be.naaturel.boardmateapi.repository;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package be.naaturel.boardmateapi.repository.test;
|
||||
package be.naaturel.boardmateapi.repository;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CustomPartyRepoImpl implements CustomPartyRepo{
|
||||
|
||||
@Override
|
||||
@@ -1,10 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package be.naaturel.boardmateapi.services;
|
||||
|
||||
import be.naaturel.boardmateapi.models.Party;
|
||||
import be.naaturel.boardmateapi.repository.test.CustomPartyRepoImpl;
|
||||
import be.naaturel.boardmateapi.repository.CustomPartyRepoImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -9,6 +10,7 @@ public class PartyService {
|
||||
|
||||
private final CustomPartyRepoImpl repo;
|
||||
|
||||
@Autowired
|
||||
public PartyService(CustomPartyRepoImpl repo){
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
spring.application.name=boardmate-api
|
||||
|
||||
#=============SERVER=============
|
||||
server.port=8000
|
||||
server.port=8080
|
||||
server.address=0.0.0.0
|
||||
|
||||
#=============SECURITY=============
|
||||
sec.cors.authorizedHots=*
|
||||
@@ -11,4 +12,9 @@ sec.cors.authorizedHeader=Authorization,Content-type
|
||||
|
||||
#=============METRICS=============
|
||||
management.endpoints.web.exposure.include=*
|
||||
management.endpoint.prometheus.enabled=true
|
||||
management.endpoint.health.show-details=always
|
||||
management.endpoint.prometheus.enabled=true
|
||||
|
||||
#=============DOCUMENTATION=============
|
||||
springdoc.swagger-ui.path=/api-docs
|
||||
springdoc.api-docs.path=/v1/api-docs
|
||||
Reference in New Issue
Block a user