From 0b6145be0217b639fa1c7b2adc001a6808223094 Mon Sep 17 00:00:00 2001 From: gustavofg1pontes Date: Tue, 24 Sep 2024 20:07:40 -0300 Subject: [PATCH] feat: return ticketId when creating enrollment --- .../java/br/com/ifsp/tickets/infra/api/EnrollmentAPI.java | 2 +- .../tickets/infra/api/controllers/EnrollmentController.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/EnrollmentAPI.java b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/EnrollmentAPI.java index a994fdc..5e03c99 100644 --- a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/EnrollmentAPI.java +++ b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/EnrollmentAPI.java @@ -21,7 +21,7 @@ public interface EnrollmentAPI { @ApiResponse(responseCode = "201", description = "Enrollment created successfully"), @ApiResponse(responseCode = "400", description = "Invalid request") }) - ResponseEntity create(@RequestBody CreateEnrollmentRequest request); + ResponseEntity create(@RequestBody CreateEnrollmentRequest request); @GetMapping(value = "/list", produces = "application/json") @ApiResponses(value = { diff --git a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/controllers/EnrollmentController.java b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/controllers/EnrollmentController.java index 36d1bd7..76ba3a2 100644 --- a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/controllers/EnrollmentController.java +++ b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/api/controllers/EnrollmentController.java @@ -24,7 +24,7 @@ public class EnrollmentController implements EnrollmentAPI { private final EnrollmentService enrollmentService; @Override - public ResponseEntity create(CreateEnrollmentRequest request) { + public ResponseEntity create(CreateEnrollmentRequest request) { final UserJpaEntity authenticatedUser = (UserJpaEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); final CreateEnrollmentInput input = CreateEnrollmentInput.of( authenticatedUser.toAggregate(), @@ -36,7 +36,7 @@ public ResponseEntity create(CreateEnrollmentRequest request) { ); final CreateEnrollmentOutput out = this.enrollmentService.create(input); - return ResponseEntity.created(URI.create("/v1/enrollment/" + out.enrollmentId())).build(); + return ResponseEntity.created(URI.create("/v1/enrollment/" + out.enrollmentId())).body(out.ticketId()); } @Override