adamsaghy commented on code in PR #6021:
URL: https://github.com/apache/fineract/pull/6021#discussion_r3474157327


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java:
##########
@@ -339,17 +355,15 @@ public String create(@Parameter(hidden = true) final 
String apiRequestBodyAsJson
     @Operation(summary = "Unassign a Staff", operationId = 
"unassignLoanOfficerGroup", description = "Allows you to unassign the 
Staff.\n\n"
             + "Mandatory Fields: staffId")
     @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
GroupsApiResourceSwagger.PostGroupsGroupIdCommandUnassignStaffRequest.class)))
-    @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
GroupsApiResourceSwagger.PostGroupsGroupIdCommandUnassignStaffResponse.class)))
     public String unassignLoanOfficer(@PathParam("groupId") 
@Parameter(description = "groupId") final Long groupId,
-            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
-
-        final CommandWrapper commandRequest = new CommandWrapperBuilder() //
-                .unassignGroupStaff(groupId) //
-                .withJson(apiRequestBodyAsJson) //
-                .build(); //
-        final CommandProcessingResult result = 
commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        return toApiJsonSerializer.serialize(result);
-
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) 
throws java.io.IOException {
+
+        final GroupUnassignStaffRequest request = 
objectMapper.readValue(apiRequestBodyAsJson, GroupUnassignStaffRequest.class);
+        request.setGroupId(groupId);
+        final var command = new GroupUnassignStaffCommand();
+        command.setPayload(request);
+        final java.util.function.Supplier<GroupUnassignStaffResponse> response 
= commandDispatcher.dispatch(command);
+        return toApiJsonSerializer.serialize(response.get());

Review Comment:
   Dont serialize the response. Use directly the `GroupUnassignStaffResponse`. 
Also please use import for `java.util.function.Supplier`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to