From f23eb1074875e6a004786dc8b425a4fd318e0fd0 Mon Sep 17 00:00:00 2001 From: Shishir Suman <shishir.suman@tarento.com> Date: Thu, 25 Jan 2024 19:42:56 +0530 Subject: [PATCH] bug fixes --- .../grievance/controller/UserController.java | 15 ++++++++++++--- .../grievance/service/IntegrationService.java | 3 ++- .../service/impl/IntegrationServiceImpl.java | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/upsmf/grievance/controller/UserController.java b/src/main/java/org/upsmf/grievance/controller/UserController.java index 478d487..fa6c8fa 100644 --- a/src/main/java/org/upsmf/grievance/controller/UserController.java +++ b/src/main/java/org/upsmf/grievance/controller/UserController.java @@ -144,10 +144,19 @@ public class UserController { @PostMapping("/activate") public ResponseEntity activateUser(@RequestBody JsonNode payload) { try { - ResponseEntity<?> response = integrationService.activateUser(payload); + ResponseEntity<Response> response = integrationService.activateUser(payload); if(response.getStatusCode().value() == HttpStatus.OK.value()) { - User user = (User) response.getBody(); - return createUserResponse(user); + log.info("activating user - {}", response); + Response responseBody = response.getBody(); + log.info("activating user - response body {}", responseBody); + if(responseBody != null + && responseBody.getBody() != null + && responseBody.getStatus() == HttpStatus.OK.value()) { + User user = (User)responseBody.getBody(); + log.info("activating user - response body | user {}", user); + return createUserResponse(user); + } + } return response; } catch (Exception e) { diff --git a/src/main/java/org/upsmf/grievance/service/IntegrationService.java b/src/main/java/org/upsmf/grievance/service/IntegrationService.java index acb0b01..d752bc6 100644 --- a/src/main/java/org/upsmf/grievance/service/IntegrationService.java +++ b/src/main/java/org/upsmf/grievance/service/IntegrationService.java @@ -7,6 +7,7 @@ import org.upsmf.grievance.dto.CreateUserDto; import org.upsmf.grievance.dto.UpdateUserDto; import org.upsmf.grievance.dto.UserResponseDto; import org.upsmf.grievance.model.User; +import org.upsmf.grievance.model.reponse.Response; import java.util.List; import java.util.Optional; @@ -28,7 +29,7 @@ public interface IntegrationService { void assignRole(Long userId, Long roleId) throws NotFoundException; - ResponseEntity<?> activateUser(JsonNode payload) throws Exception; + ResponseEntity<Response> activateUser(JsonNode payload) throws Exception; User deactivateUser(JsonNode payload) throws Exception; diff --git a/src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java b/src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java index 0967d8f..c68885b 100644 --- a/src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java +++ b/src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java @@ -835,7 +835,7 @@ public class IntegrationServiceImpl implements IntegrationService { } @Override - public ResponseEntity<?> activateUser(JsonNode payload) throws Exception { + public ResponseEntity<Response> activateUser(JsonNode payload) throws Exception { long id = payload.get("id").asLong(-1); if (id > 0) { Optional<User> user = userRepository.findById(id); -- GitLab