Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1214,4 +1214,19 @@ private JSONObject prepareAuthenticationResponse(User mUser, String remoteAddres
return iemrAdminUserServiceImpl.generateKeyAndValidateIP(responseObj, remoteAddress, remoteHost);
}

@Operation(summary = "Get UserId based on userName")
@GetMapping(value = "/userName/{userName}", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public ResponseEntity<?> getUserDetails(@PathVariable("userName") String userName) {
try {
List<User> users = iemrAdminUserServiceImpl.getUserIdbyUserName(userName);
if (users.isEmpty()) {
return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND);
}
User user = users.get(0);
return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public List<ServiceRoleScreenMapping> getUserServiceRoleMappingForProvider(Integ

List<UserServiceRoleMapping> getUserServiceRoleMapping(Long userID) throws IEMRException;

List<User> getUserIdbyUserName(String userName) throws IEMRException;



}
Original file line number Diff line number Diff line change
Expand Up @@ -1218,4 +1218,10 @@ public User getUserById(Long userId) throws IEMRException {
throw new IEMRException("Error fetching user with ID: " + userId, e);
}
}

@Override
public List<User> getUserIdbyUserName(String userName) {

return iEMRUserRepositoryCustom.findByUserName(userName);
}
}