vidakovic commented on code in PR #5622:
URL: https://github.com/apache/fineract/pull/5622#discussion_r3004539530
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/api/ProductMixApiResource.java:
##########
@@ -89,35 +96,44 @@ public String retrieveTemplate(@PathParam("productId")
final Long productId, @Co
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
- public CommandProcessingResult createProductMix(@PathParam("productId")
final Long productId,
- final ProductMixRequest productMixRequest) {
+ public ProductMixCreateResponse createProductMix(@PathParam("productId")
final Long productId, @Valid final ProductMixRequest request) {
+
+ final var payload = new ProductMixCreateRequest();
+ payload.setProductId(productId);
+ payload.setRestrictedProducts(request.getRestrictedProducts());
- final CommandWrapper commandRequest = new
CommandWrapperBuilder().createProductMix(productId)
-
.withJson(toApiJsonSerializer.serialize(productMixRequest)).build();
+ final var command = new ProductMixCreateCommand();
+ command.setPayload(payload);
- return
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+ final Supplier<ProductMixCreateResponse> response =
commandDispatcher.dispatch(command);
+ return response.get();
}
@PUT
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
- public CommandProcessingResult updateProductMix(@PathParam("productId")
final Long productId,
- final ProductMixRequest productMixRequest) {
+ public ProductMixUpdateResponse updateProductMix(@PathParam("productId")
final Long productId, @Valid final ProductMixRequest request) {
- final CommandWrapper commandRequest = new
CommandWrapperBuilder().updateProductMix(productId)
-
.withJson(toApiJsonSerializer.serialize(productMixRequest)).build();
+ final var payload = new ProductMixUpdateRequest();
Review Comment:
Why not use `ProductMixUpdateRequest` as a function parameter aka the body?
Then you can get rid of the `ProductMixRequest` class. Same for the create
method.
--
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]