-
Notifications
You must be signed in to change notification settings - Fork 4
create -interfaces-and-controller-signatures. #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,43 @@ | ||
| package com.educare.unitylend.controller; | ||
|
|
||
| import com.educare.unitylend.service.BorrowRequestCommunityMapService; | ||
| import com.educare.unitylend.Exception.ControllerException; | ||
| import com.educare.unitylend.Exception.ServiceException; | ||
| import com.educare.unitylend.model.BorrowRequest; | ||
| import com.educare.unitylend.model.Status; | ||
| import com.educare.unitylend.service.BorrowRequestService; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/borrow-request") | ||
| import java.util.List; | ||
|
|
||
| public class BorrowRequestController extends BaseController{ | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use proper annotations for Parameters and Request Body |
||
|
|
||
| ResponseEntity<List<BorrowRequest>> getAllBorrowRequests() throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<List<BorrowRequest>> getBorrowRequestForUserId(String userId) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<Void> createBorrowRequest(@RequestBody BorrowRequest borrowRequest) throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make return type |
||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<List<BorrowRequest>> getBorrowRequestForCommunity(@RequestParam List<String> communityId) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<Void> updateEMIDefaults() throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make return type
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove updateEMIdefaults and updateBorrowRequestStatus |
||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<Void> updateBorrowRequestStatus(@RequestBody Status status) throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make return type |
||
| return null; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,36 @@ | ||
| package com.educare.unitylend.controller; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/transaction") | ||
| import com.educare.unitylend.Exception.ControllerException; | ||
| import com.educare.unitylend.model.Transaction; | ||
| import com.educare.unitylend.model.User; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public class TransactionController extends BaseController{ | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove semi-colons |
||
| ResponseEntity<List<Transaction>> getTransactionsBySender(@PathVariable String userId) throws ControllerException{ | ||
| return null; | ||
| }; | ||
|
|
||
| ResponseEntity<List<Transaction>> getTransactionsBetween(@PathVariable String senderId, @PathVariable String receiverId) throws ControllerException | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this to a better name |
||
| { | ||
| return null; | ||
| }; | ||
| ResponseEntity<List<Transaction>> getAllTransactions() throws ControllerException | ||
| { | ||
| return null; | ||
| }; | ||
|
|
||
| ResponseEntity<List<Transaction>> getTransactionsByDate(@PathVariable LocalDate date) throws ControllerException | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getTransactionsBetweenDate(start,end) |
||
| { | ||
| return null; | ||
| }; | ||
| ResponseEntity<Transaction> initiateTransaction( @RequestBody Transaction transaction) throws ControllerException | ||
| { | ||
| return null; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,16 +6,40 @@ | |
| import com.educare.unitylend.service.UserService; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/user") | ||
| public class UserController extends BaseController{ | ||
| public class UserController { | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Param and RequestBody Annotations
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the methods throw ControllerException, not ServiceException
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this class extend BaseController |
||
|
|
||
|
|
||
| ResponseEntity<List<User>> getAllUsers() throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throw controller exception
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comments for administration purposes |
||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<User> updateUser(User user) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<User> createUser(User user) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<User> getUserById(String userId) throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to getUserForUserId |
||
| return null; | ||
| } | ||
|
|
||
| ResponseEntity<Void> deleteUser(String userId) throws ServiceException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make return type |
||
| return null; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,25 @@ | ||
| package com.educare.unitylend.service; | ||
|
|
||
| import com.educare.unitylend.Exception.ServiceException; | ||
| import com.educare.unitylend.model.BorrowRequest; | ||
| import com.educare.unitylend.model.Status; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface BorrowRequestService { | ||
|
|
||
| // List<String> getRequestedCommunitiesByUserId(String userId) throws ServiceException; | ||
| List<BorrowRequest> getAllBorrowRequests() throws ServiceException; | ||
| List<BorrowRequest> getBorrowRequestForUserId(String userId) throws ServiceException; | ||
| boolean createBorrowRequest(BorrowRequest borrowRequest) throws ServiceException; | ||
|
|
||
| List<BorrowRequest> getBorrowRequestForCommunity(List <String> communityId ) throws ServiceException; | ||
|
|
||
|
|
||
| boolean updateEMIDefaults() throws ServiceException; | ||
|
|
||
| boolean updateBorrowRequestStatus(Status status) throws ServiceException; | ||
|
|
||
| // boolean raiseBorrowRequestByUserId(String userId, BorrowRequest borrowRequest) throws ServiceException; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,22 @@ | ||
| package com.educare.unitylend.service; | ||
|
|
||
| import com.educare.unitylend.Exception.ControllerException; | ||
| import com.educare.unitylend.Exception.ServiceException; | ||
| import com.educare.unitylend.model.Transaction; | ||
| import com.educare.unitylend.model.User; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| public interface TransactionService { | ||
|
|
||
| List<Transaction> getTransactionsBySender(User sender) throws ControllerException; | ||
|
|
||
| List<Transaction> getTransactionsBetween(User sender, User receiver) throws ControllerException; | ||
|
|
||
| List<Transaction> getAllTransactions() throws ControllerException; | ||
|
|
||
| List<Transaction> getTransactionsByDate(LocalDate date) throws ControllerException; | ||
|
|
||
| boolean initiateTransaction(Transaction transaction) throws ControllerException; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,86 @@ | ||
| package com.educare.unitylend.service.impl; | ||
|
|
||
| import com.educare.unitylend.Exception.ServiceException; | ||
| import com.educare.unitylend.model.BorrowRequest; | ||
| import com.educare.unitylend.model.Status; | ||
| import com.educare.unitylend.service.BorrowRequestService; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @Service | ||
| public class BorrowRequestServiceImpl implements BorrowRequestService { | ||
| @Override | ||
| public List<BorrowRequest> getAllBorrowRequests() throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<BorrowRequest> getBorrowRequestForUserId(String userId) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean createBorrowRequest(BorrowRequest borrowRequest) throws ServiceException { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public List<BorrowRequest> getBorrowRequestForCommunity(List <String> communityId) throws ServiceException { | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public boolean updateEMIDefaults() throws ServiceException { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean updateBorrowRequestStatus(Status status) throws ServiceException { | ||
| return false; | ||
| } | ||
|
|
||
| // private UserRepository userRepository; | ||
| // private BorrowRequestRepository borrowRequestRepository; | ||
| // public List<String> getRequestedCommunitiesByUserId(String userId) throws ServiceException{ | ||
| // List<String> communities=borrowRequestRepository.getBorrowRequestByUserId(userId); | ||
| // System.out.println(communities); | ||
| // return communities; | ||
| // } | ||
| // | ||
| // public void createBorrowRequest(BorrowRequest borrowRequest) { | ||
| // borrowRequestRepository.createBorrowRequest(borrowRequest); | ||
| // } | ||
| // public boolean raiseBorrowRequestByUserId(String userId, BorrowRequest borrowRequest) throws ServiceException { | ||
| // try { | ||
| // // Assuming returnPeriod is in days | ||
| // BigDecimal monthlyInterestRate = new BigDecimal("50.0").divide(new BigDecimal(12 * 100), 10, RoundingMode.HALF_UP); | ||
| // BigDecimal loanTenureMonths = new BigDecimal(borrowRequest.getReturnPeriod()).multiply(new BigDecimal("30.44")); | ||
| // double pow = Math.pow(1 + monthlyInterestRate.doubleValue(), loanTenureMonths.doubleValue()); | ||
| // BigDecimal emiNumerator = borrowRequest.getTargetAmount() | ||
| // .multiply(new BigDecimal(pow)).multiply(new BigDecimal(50)); | ||
| // | ||
| // | ||
| // BigDecimal emiDenominator = new BigDecimal(pow - 1); | ||
| // | ||
| // BigDecimal emi = emiNumerator.divide(emiDenominator, 2, RoundingMode.HALF_UP); | ||
| // // BigDecimal emi =borrowRequest.getTargetAmount().divide(new BigDecimal(borrowRequest.getReturnPeriod())); | ||
| // if (emi.compareTo(new BigDecimal(userRepository.getIncome(userId)).divide(new BigDecimal(2), 2, RoundingMode.HALF_UP)) <0) { | ||
| // return false; | ||
| // } | ||
| // return true; | ||
| // | ||
| // } catch (Exception e) { | ||
| // throw new ServiceException("Error in calculating EMI", e); | ||
| // } | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,43 @@ | ||
| package com.educare.unitylend.service.impl; | ||
|
|
||
| import com.educare.unitylend.Exception.ControllerException; | ||
| import com.educare.unitylend.Exception.ServiceException; | ||
| import com.educare.unitylend.model.Transaction; | ||
| import com.educare.unitylend.model.User; | ||
| import com.educare.unitylend.service.TransactionService; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @Service | ||
| public class TransactionServiceImpl implements TransactionService { | ||
| @Override | ||
| public List<Transaction> getTransactionsBySender(User sender) throws ControllerException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Transaction> getTransactionsBetween(User sender, User receiver) throws ControllerException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Transaction> getAllTransactions() throws ControllerException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Transaction> getTransactionsByDate(LocalDate date) throws ControllerException { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean initiateTransaction(Transaction transaction) throws ControllerException { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the methods throw ControllerException, not ServiceException