vidakovic commented on code in PR #5613:
URL: https://github.com/apache/fineract/pull/5613#discussion_r2924293054
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java:
##########
@@ -50,81 +47,80 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.function.Supplier;
import lombok.RequiredArgsConstructor;
-import org.apache.fineract.commands.domain.CommandWrapper;
-import org.apache.fineract.commands.service.CommandWrapperBuilder;
-import
org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.command.core.CommandPipeline;
import org.apache.fineract.infrastructure.core.api.ApiParameterHelper;
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import
org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import
org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
-import
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import
org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants;
+import
org.apache.fineract.portfolio.interestratechart.command.InterestRateChartCreateCommand;
+import
org.apache.fineract.portfolio.interestratechart.command.InterestRateChartDeleteCommand;
+import
org.apache.fineract.portfolio.interestratechart.command.InterestRateChartUpdateCommand;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateResponse;
import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData;
-import
org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteResponse;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest;
+import
org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateResponse;
+import
org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService;
import org.springframework.stereotype.Component;
@Path("/v1/interestratecharts")
@Component
+@Consumes({ MediaType.APPLICATION_JSON })
+@Produces({ MediaType.APPLICATION_JSON })
@Tag(name = "Interest Rate Chart", description = "This defines an interest
rate scheme that can be associated to a term deposit product. This will have a
slab (band or range) of deposit periods and the associated interest rates
applicable along with incentives for each band.")
@RequiredArgsConstructor
public class InterestRateChartsApiResource {
- private final InterestRateChartReadPlatformService
chartReadPlatformService;
- private final PlatformSecurityContext context;
- private final DefaultToApiJsonSerializer<InterestRateChartData>
toApiJsonSerializer;
- private final PortfolioCommandSourceWritePlatformService
commandsSourceWritePlatformService;
- private final ApiRequestParameterHelper apiRequestParameterHelper;
private static final Set<String>
INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(
InterestRateChartApiConstants.localeParamName,
InterestRateChartApiConstants.dateFormatParamName, idParamName, nameParamName,
descriptionParamName, fromDateParamName, endDateParamName,
chartSlabs, isPrimaryGroupingByAmountParamName));
+ private final InterestRateChartReadService chartReadPlatformService;
+
+ private final DefaultToApiJsonSerializer<InterestRateChartData>
jsonSerializer;
+
+ private final ApiRequestParameterHelper apiRequestParameterHelper;
+
+ private final CommandPipeline commandPipeline;
+
@GET
@Path("template")
- @Consumes({ MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_JSON })
- @Operation(summary = "Retrieve Chart Details Template", description =
"This is a convenience resource. It can be useful when building maintenance
user interface screens for creating a chart. The template data returned
consists of any or all of:\n"
- + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example
Request:\n" + "\n" + "interestratecharts/template")
- @ApiResponse(responseCode = "200", description = "OK", content =
@Content(schema = @Schema(implementation =
InterestRateChartsApiResourceSwagger.GetInterestRateChartsTemplateResponse.class)))
+ @Operation(summary = "Retrieve Chart Details Template", description = """
+ This is a convenience resource. It can be useful when building
maintenance user interface screens for creating a chart. The template data
returned consists of any or all of: Field Defaults Allowed Value Lists
+ Example Request: interestratecharts/template
+ """)
public String template(@Context final UriInfo uriInfo) {
-
this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME);
-
InterestRateChartData chartData =
this.chartReadPlatformService.template();
final ApiRequestJsonSerializationSettings settings =
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
- return this.toApiJsonSerializer.serialize(settings, chartData,
INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS);
+ return this.jsonSerializer.serialize(settings, chartData,
INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS);
}
@GET
- @Consumes({ MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_JSON })
- @Operation(summary = "Retrieve all Charts", description = "Retrieve list
of charts associated with a term deposit product(FD or RD).\n"
- + "Example Requests:\n" + "\n" + "interestratecharts?productId=1")
- @ApiResponse(responseCode = "200", description = "OK", content =
@Content(array = @ArraySchema(schema = @Schema(implementation =
InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.class))))
+ @Operation(summary = "Retrieve all Charts", description = """
+ Retrieve list of charts associated with a term deposit product(FD
or RD).
+ Example Requests: interestratecharts?productId=1
+ """)
public String retrieveAll(@Context final UriInfo uriInfo,
@QueryParam("productId") @Parameter(description = "productId")
final Long productId) {
-
this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME);
-
Collection<InterestRateChartData> chartDatas =
this.chartReadPlatformService.retrieveAllWithSlabs(productId);
final ApiRequestJsonSerializationSettings settings =
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
- return this.toApiJsonSerializer.serialize(settings, chartDatas,
INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS);
+ return this.jsonSerializer.serialize(settings, chartDatas,
INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS);
Review Comment:
Nope. None of that manual JSON de-/serialization allowed here... and not
necessary.
--
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]