feat: finished implementing apiService functions

This commit is contained in:
Théo Le Lez
2025-03-19 12:05:56 +01:00
parent c94d3654ce
commit 3c61fdca93
3 changed files with 67 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.controller;
import com.itextpdf.text.DocumentException;
import enseirb.myinpulse.model.*;
import enseirb.myinpulse.service.SharedApiService;
@ -10,7 +11,8 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
@SpringBootApplication
@RestController
@ -83,10 +85,12 @@ public class SharedApi {
@PathVariable int appointmentId, @AuthenticationPrincipal Jwt principal) {
try {
sharedApiService.getPDFReport(appointmentId, principal.getClaimAsString("email"));
} catch (FileNotFoundException e) {
System.out.println(e + "File not found");
} catch (DocumentException e) {
System.out.println(e + "Document exception");
} catch (URISyntaxException e) {
System.out.println(e + "Error with URI");
} catch (IOException e) {
System.out.println(e + "Failed to access file");
}
}