Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/FullStack.MicroWebApplication-Server.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__io_micrometer_micrometer_core_1_6_2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_hdrhistogram_HdrHistogram_2_1_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_latencyutils_LatencyUtils_2_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@
<artifactId>generex</artifactId>
<version>1.0.1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
39 changes: 15 additions & 24 deletions src/main/java/runner/services/CustomerServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.stereotype.Service;
import runner.entities.Login;
import runner.repositories.CustomerRepo;
import runner.repositories.LoginRepo;
import java.text.ParseException;
import java.util.*;
import java.util.logging.Level;
Expand All @@ -19,10 +18,10 @@

@Service
public class CustomerServices {
//object for logging information,warning,error
//object for logging information,warning,error
private final static Logger loggerService = Logger.getLogger(CustomerServices.class.getName());
private CustomerRepo customerRepo;
//Autowired the customerService
//Autowired the customerService
@Autowired
public CustomerServices(CustomerRepo customerRepo) {
loggerService.log(Level.INFO, "The repository for customer has been autowired to services");
Expand All @@ -32,7 +31,7 @@ public CustomerServices(CustomerRepo customerRepo) {
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;

//save the customer in the DB
//Save the customer in the DB
public Customer createCustomer(Customer customer) {
loggerService.log(Level.INFO, "The customer information is being checked");
if(!checkLogin(customer.getLogin())) {
Expand All @@ -45,13 +44,16 @@ public Customer createCustomer(Customer customer) {
}
return null;
}

//Check if the username already exist
public Boolean checkLogin(Login login) {

List<String> logins= customerRepo.findAllLoginsNative();
long count = logins.stream().filter(name -> name.equalsIgnoreCase(login.getUsername())).count();
return count!=0 ? true:false;
}

//Find the customer from DB using id
public Customer readCustomer(Long id) {
loggerService.log(Level.INFO, "The customer information is being read");
Customer customer = customerRepo.findCustomerById(id);
Expand All @@ -64,10 +66,9 @@ public Customer readCustomer(Long id) {
}
}


//Find Customer from DB using the logged in user name
public Customer readCustomerByLogin(String name) {
loggerService.log(Level.INFO, "The customer information is being read");
// Login login =
Customer customer = customerRepo.findCustomerByLoginUsername(name);
if (customer != null) {
loggerService.log(Level.INFO, "The customer is found and being returned");
Expand All @@ -77,7 +78,7 @@ public Customer readCustomerByLogin(String name) {
return null;
}
}

//Delete the customer from DB after checking that all account balance are < 0
public int deleteCustomer(Long id) {
Customer customer = customerRepo.findCustomerById(id);
Set<Account> accounts; // To collect all accounts belonging to this customer
Expand All @@ -99,6 +100,7 @@ else if(result.size()>0) {
return 1;
}

//Update the Customer (all fields) in the DB ,based on body of request
public Customer updateCustomer(Long id, Customer customer) throws Exception {
loggerService.log(Level.INFO, "Finding the customer to be updated");
Customer customerFromDB = customerRepo.findCustomerById(id);
Expand All @@ -108,14 +110,13 @@ public Customer updateCustomer(Long id, Customer customer) throws Exception {
customer.getAddress().setId(customerFromDB.getAddress().getId());
customer.setId(customerFromDB.getId());
accountSetFromDB = customerFromDB.getAccounts();
//Once the existing accounts are added , we will add more accounts
//Once the existing accounts are added , we will add more accounts from the request body
for (Account account : customer.getAccounts()) {
account.setCustomer(customerFromDB);
account.setEncryptedUrl(generateRandomUrl());
accountSetFromDB.add(account);
}
customer.setAccounts(accountSetFromDB);

customerRepo.save(customer);
loggerService.log(Level.INFO, "Customer with Id " + customerFromDB.getId() + "has been updated");
return customerFromDB;
Expand All @@ -125,7 +126,8 @@ public Customer updateCustomer(Long id, Customer customer) throws Exception {
}
}


//Update phone number ,check syntax based on the REGEX
//Returns 0 = Updated , 1 : Customer not found , 2 : Phone number format not correct
public int updateCustomerPhoneNumber(Long id, String phone) throws ParseException {
loggerService.log(Level.INFO, "Finding the customer to be updated");
Customer customer = customerRepo.findCustomerById(id);
Expand All @@ -146,6 +148,8 @@ public int updateCustomerPhoneNumber(Long id, String phone) throws ParseExceptio
return 2;
}

//Update Email number ,check syntax based on the REGEX
//Returns 0 = Updated , 1 : Customer not found , 2 : Email format not correct
public int updateCustomerEmail(Long id, String email) {
//return 0 when updated , 1 is customer not found and 2 if value does not match the REGEX
loggerService.log(Level.INFO, "Finding the user to be updated");
Expand All @@ -167,7 +171,7 @@ public int updateCustomerEmail(Long id, String email) {
}
return 2;
}

//Update Customer address
public Customer updateCustomerAddress(Long id, Address address) {
loggerService.log(Level.INFO, "Finding the customer to be updated");
Customer customer = customerRepo.findCustomerById(id);
Expand All @@ -194,19 +198,6 @@ public Set<Account> getAllAccounts(Long id) {
return null;
}

//superceded by Set<Account> findAccountsByCustomer_LoginUsername (String login) in AccountRepo
/* public Set<Account> getAllAccounts(String username) {
loggerService.log(Level.INFO, "Finding the customer to get all accounts");
Login login = loginRepo.findLoginByUsername(username);
Customer customer = customerRepo.findCustomerById(login.getId());

if (customer != null) {
loggerService.log(Level.INFO, "Accounts belonging to "+login.getId()+ " use has been found ,accounts are being returned");
return customer.getAccounts();
}
return null;
}*/

//generate 35-40 random characters
public String generateRandomUrl() {
Generex generex = new Generex("[A-Za-z0-9]{35,40}");
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/runner/services/TransactionServices.class
Binary file not shown.
3 changes: 3 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifactId=FullStack.MicroWebApplication-Server
groupId=groupId
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
runner/enums/AccountType.class
runner/repositories/AccountRepo.class
runner/repositories/LoginRepo.class
runner/controllers/CustomerController.class
runner/entities/Transaction.class
runner/security/controllers/AuthenticationController.class
runner/views/Views$AccountSpecific.class
runner/services/AccountServices.class
runner/controllers/TestHomePageDeleteLater.class
runner/views/Views$PhoneNumber.class
runner/views/Views$AccountActions.class
runner/views/Views.class
runner/AppRunner.class
runner/security/config/WebSecurityConfig.class
runner/views/Views$AccountDetails.class
runner/controllers/TransactionController.class
runner/views/Views$Email.class
runner/entities/Login.class
runner/repositories/TransactionRepo.class
runner/repositories/CustomerRepo.class
runner/views/Views$AccountType.class
runner/entities/Address.class
runner/security/utilities/JwtUtil.class
runner/views/Views$Profile.class
runner/services/LoginServices.class
runner/controllers/AccountController.class
runner/entities/Investment.class
runner/services/TransactionServices.class
runner/entities/Customer.class
runner/controllers/LoginController.class
runner/services/CustomerServices.class
runner/security/filters/JwtAuthorizationFilter.class
runner/views/Views$AccountNumber.class
runner/entities/Checking.class
runner/entities/Account.class
runner/views/Views$Address.class
runner/views/Views$AllAccounts.class
runner/entities/Savings.class
runner/security/models/AuthenticationResponse.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/security/controllers/AuthenticationController.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/controllers/TestHomePageDeleteLater.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/repositories/TransactionRepo.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/enums/AccountType.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/controllers/CustomerController.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Investment.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/services/TransactionServices.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/repositories/CustomerRepo.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/controllers/AccountController.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/controllers/TransactionController.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/controllers/LoginController.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/security/utilities/JwtUtil.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Customer.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/repositories/AccountRepo.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/views/Views.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Savings.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/security/filters/JwtAuthorizationFilter.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/services/LoginServices.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/security/config/WebSecurityConfig.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Account.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/services/CustomerServices.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/repositories/LoginRepo.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/services/AccountServices.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Transaction.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/security/models/AuthenticationResponse.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Checking.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/AppRunner.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Address.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/main/java/runner/entities/Login.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
runner/configuration/CustomerServiceTestConfiguration.class
runner/security/JwtTest.class
runner/controllers/CustomerControllerTest.class
runner/controllers/AccountControllerTest.class
runner/services/CustomerServiceTest.class
runner/entities/AccountEntityTest.class
runner/configuration/AccountServiceTestConfiguration.class
runner/services/AccountServiceTest.class
runner/entities/CustomerEntityTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/controllers/AccountControllerTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/services/CustomerServiceTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/entities/AccountEntityTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/services/AccountServiceTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/entities/CustomerEntityTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/configuration/CustomerServiceTestConfiguration.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/controllers/CustomerControllerTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/security/JwtTest.java
/Users/gunjan/Dev/FullStack.MicroWebApplication-Server/src/test/java/runner/configuration/AccountServiceTestConfiguration.java
Binary file modified target/test-classes/runner/services/AccountServiceTest.class
Binary file not shown.