PMT-37-added Controller Method

This commit is contained in:
Ole Kück 2024-10-23 15:30:13 +02:00
parent cec89e2766
commit 6eb1b5bda8
Signed by: SZUT-Ole
GPG key ID: 0A1DF1B37C4A1E4C

View file

@ -72,6 +72,28 @@ public class ApiController implements DefaultApi {
return ResponseEntity.ok(response);
}
@Override
public ResponseEntity<GetAllProjectInfoDTO> getProjectInfo(Long id){
GetAllProjectInfoDTO response = new GetAllProjectInfoDTO();
Optional<Project> 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<Void> updateProject(Long id, UpdateProjectDTO body) {
Optional<Project> optionalProject = projectRepository.findById(id);