Created a new endpoint to update user

This commit is contained in:
rajesh
2025-02-06 20:33:40 +05:30
parent eeb01ab8fa
commit da677ca039
6 changed files with 116 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ public interface UserApi {
return new ResponseEntity<Response<JWTToken>>(HttpStatus.NOT_IMPLEMENTED);
}
@Operation(summary = "Api to update user",
@Operation(summary = "Api to update user (Only for super admin)",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -243,6 +243,24 @@ public interface UserApi {
@RequestMapping("favicon.ico")
@ResponseBody
void returnNoFavicon();
@Operation(summary = "Api to update user",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
@RequestMapping(value = "/{userId}/update-details",
produces = {"application/json"},
method = RequestMethod.PUT)
default ResponseEntity<Response<UserResponseBean>> updateUserDetails(HttpServletRequest request,
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
@Parameter(description = "User request object", required = true) @Valid @RequestBody UpdateUserReqForBeneficiary userReq) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}

View File

@@ -247,5 +247,21 @@ public class UserApiController implements UserApi {
public void returnNoFavicon() {
// Do nothing
}
@Override
public ResponseEntity<Response<UserResponseBean>> updateUserDetails(HttpServletRequest request,
@PathVariable("userId") Long userId,
@Valid @RequestBody UpdateUserReqForBeneficiary userReq) {
log.info("Update User for Beneficiary- User ID: {}, Request Body: {}", userId, userReq);
/** This code is responsible for "Updating user details by beneficiary" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPDATE_USER_DETAILS).build());
UserResponseBean updatedUser = userService.updateUserDetails(request, userId, userReq);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(updatedUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_UPDATED_SUCCESS_MSG)));
}
}