From 6eb1b5bda8557c65388d5cd53bd3e84271760fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20K=C3=BCck?= Date: Wed, 23 Oct 2024 15:30:13 +0200 Subject: [PATCH] PMT-37-added Controller Method --- src/main/java/de/hmmh/pmt/ApiController.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index c29c60b..e388969 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -72,6 +72,28 @@ public class ApiController implements DefaultApi { return ResponseEntity.ok(response); } + @Override + public ResponseEntity getProjectInfo(Long id){ + GetAllProjectInfoDTO response = new GetAllProjectInfoDTO(); + + Optional optionalProject = projectRepository.findById(id); + if (optionalProject.isEmpty()) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + Project project = optionalProject.get(); + + response.setId(project.getId()); + response.setName(project.getName()); + response.setGoal(project.getGoal()); + response.setCustomerId(project.getCustomerId()); + response.setAdministratorId(project.getAdministratorId()); + response.setStart(project.getStart()); + response.setPlannedEnd(project.getPlannedEnd()); + + return ResponseEntity.ok(response); + } + + @Override public ResponseEntity updateProject(Long id, UpdateProjectDTO body) { Optional optionalProject = projectRepository.findById(id);