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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsDetailsApiResource.java:
##########
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.portfolio.loanproduct.api;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.Collection;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import 
org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData;
+import 
org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
+import 
org.apache.fineract.portfolio.workingcapitalloanproduct.service.WorkingCapitalLoanProductReadPlatformService;
+import org.springframework.stereotype.Component;
+
+@Path("/v1/loanproducts")
+@Component
+@Tag(name = "Loan Products Details", description = "Loan product basic details 
to be listed")
+@RequiredArgsConstructor
+public class LoanProductsDetailsApiResource {
+
+    private static final String RESOURCE_NAME_FOR_PERMISSIONS = "LOANPRODUCT";
+    private final PlatformSecurityContext context;
+    private final LoanProductReadPlatformService 
loanProductReadPlatformService;
+    private final WorkingCapitalLoanProductReadPlatformService 
workingCapitalLoanProductReadPlatformService;

Review Comment:
   Create a new interface (like `LoanProductReadBasicDetailsService`) in the 
`fineract-loan` module which has the `retrieveProducts()` method.
   
   Lets have 2 implementation of this interface:
   1. in `fineract-loan` module which return those loan products
   2. in `fineract-working-capital-loan` module which return those loan products
   
   This class also can be moved into `fineract-loan` module.
   
   We dont need to explicitly inject `LoanProductReadPlatformService` and 
`WorkingCapitalLoanProductReadPlatformService`.
   
   Lets inject List of the newly created interface:
   ```
   private final List<LoanProductReadBasicDetailsService> 
loanProductReadBasicDetailsServices;
   ...
   loanProductReadBasicDetailsServices.foreach( service -> 
products.addAll(service.retrieveProducts());
   ```
   
   We dont need to put anything into `fineract-provider` module.



-- 
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