Skip to content
Snippets Groups Projects
Commit 24a85288 authored by Andreas's avatar Andreas
Browse files

refactor/Applied formatter

parent 973a6b6d
No related branches found
No related tags found
1 merge request!98refactor/Applied formatter
Pipeline #285423 passed
Showing
with 244 additions and 256 deletions
......@@ -182,6 +182,12 @@
</excludes>
</configuration>
</plugin>
<!-- spring-javaformat-maven-plugin -->
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.41</version>
</plugin>
<!-- Plugin that generates a site for the current project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
......@@ -4,8 +4,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* The main class for the Sparesti application.
* This class bootstraps the Spring application and configures it for execution.
* The main class for the Sparesti application. This class bootstraps the Spring
* application and configures it for execution.
*/
@SpringBootApplication
public class SparestiApplication {
......@@ -33,4 +33,5 @@ public class SparestiApplication {
public static String getBackendURL() {
return System.getProperty("API_URL", "http://localhost:8080");
}
}
......@@ -36,13 +36,11 @@ public class AccountController {
@Autowired
private ModelMapper modelMapper;
@Operation(summary = "Get user accounts", description = "Get accounts associated with a user by"
+ " providing their bank profile id")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@Operation(summary = "Get user accounts",
description = "Get accounts associated with a user by" + " providing their bank profile id")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@ApiResponse(responseCode = "200", description = "No accounts associated with a bank user"),
@ApiResponse(responseCode = "404", description = "Bank profile id does not exist")
})
@ApiResponse(responseCode = "404", description = "Bank profile id does not exist") })
@GetMapping("/accounts/profile/{bankProfileId}")
public ResponseEntity<List<Account>> getAccounts(@PathVariable Long bankProfileId) {
List<Account> accounts = accountService.getAccountsByBankProfileId(bankProfileId);
......@@ -53,13 +51,11 @@ public class AccountController {
return ResponseEntity.ok(accounts);
}
@Operation(summary = "Get user accounts", description = "Get accounts associated with a user by"
+ " providing their social security number")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@Operation(summary = "Get user accounts",
description = "Get accounts associated with a user by" + " providing their social security number")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@ApiResponse(responseCode = "200", description = "No accounts associated with a bank user"),
@ApiResponse(responseCode = "404", description = "Social security number does not exist")
})
@ApiResponse(responseCode = "404", description = "Social security number does not exist") })
@GetMapping("/accounts/ssn/{ssn}")
public ResponseEntity<List<Account>> getAccountsBySsn(@PathVariable Long ssn) {
List<Account> accounts = accountService.getAccountsBySsn(ssn);
......@@ -71,11 +67,8 @@ public class AccountController {
}
@Operation(summary = "Create account", description = "Create account with random balance")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully created account"),
@ApiResponse(responseCode = "404", description = "Provided bban could not be "
+ "found")
})
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully created account"),
@ApiResponse(responseCode = "404", description = "Provided bban could not be " + "found") })
@GetMapping("/balance/{bban}")
public ResponseEntity<BalanceDTO> getAccountsByBBAN(@PathVariable Long bban) {
log.info("[AccountController:getAccountsByBBAN] bban: {}", bban);
......@@ -85,15 +78,13 @@ public class AccountController {
}
@Operation(summary = "Create account", description = "Create account with random balance")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully created account"),
@ApiResponse(responseCode = "404", description = "Provided bank profile id could not be "
+ "found")
})
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully created account"),
@ApiResponse(responseCode = "404", description = "Provided bank profile id could not be " + "found") })
@PostMapping("/create-account")
public ResponseEntity<AccountResponseDTO> createAccount(@RequestBody AccountRequestDTO accountRequestDTO) {
AccountResponseDTO accountResponseDTO = accountService.saveAccount(accountRequestDTO);
log.info("[AccountController:createAccount] accountBankProfileId: {}", accountResponseDTO.getBankProfileId());
return ResponseEntity.ok(accountResponseDTO);
}
}
\ No newline at end of file
......@@ -26,12 +26,10 @@ public class BankProfileController {
@Autowired
private BankProfileService bankProfileService;
@Operation(summary = "Create bank profile", description = "Create a bank profile by providing a"
+ " social security number")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully created a bank profile"),
@ApiResponse(responseCode = "400", description = "Could not create profile")
})
@Operation(summary = "Create bank profile",
description = "Create a bank profile by providing a" + " social security number")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully created a bank profile"),
@ApiResponse(responseCode = "400", description = "Could not create profile") })
@PostMapping("/create-profile")
public BankProfileResponseDTO createBankProfile(@RequestBody BankProfileDTO bankProfileDTO) {
log.info("[BankProfileController:createBankProfile] bank-profileSsn: {}", bankProfileDTO.getSsn());
......
......@@ -26,17 +26,18 @@ public class TransactionController {
@Autowired
private TransactionService transactionService;
@Operation(summary = "Transfer to account", description = "Transfer money from a users account "
+ "to another account of the same user")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@Operation(summary = "Transfer to account",
description = "Transfer money from a users account " + "to another account of the same user")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully got accounts"),
@ApiResponse(responseCode = "200", description = "No accounts associated with a bank user"),
@ApiResponse(responseCode = "404", description = "Bank profile id does not exist")
})
@ApiResponse(responseCode = "404", description = "Bank profile id does not exist") })
@PostMapping("/norwegian-domestic-payment-to-self")
public ResponseEntity<TransactionDTO> transferToSelf(@RequestBody TransactionDTO transactionRequest) {
transactionService.saveTransaction(transactionRequest);
log.info("[TransactionController:transferToSelf] transaction amount {} from: {} -> {}", transactionRequest.getAmount(), transactionRequest.getCreditorBBAN(), transactionRequest.getDebtorBBAN());
log.info("[TransactionController:transferToSelf] transaction amount {} from: {} -> {}",
transactionRequest.getAmount(), transactionRequest.getCreditorBBAN(),
transactionRequest.getDebtorBBAN());
return ResponseEntity.ok(transactionRequest);
}
}
......@@ -10,6 +10,7 @@ import lombok.Data;
public class AccountResponseDTO {
private Long bankProfileId;
private BigDecimal balance;
}
......@@ -7,5 +7,7 @@ import lombok.Data;
public final class BalanceDTO {
private Long bban;
private BigDecimal balance;
}
......@@ -11,6 +11,7 @@ import no.ntnu.idi.stud.savingsapp.bank.model.Account;
public class BankProfileResponseDTO {
private Long ssn;
List<Account> accounts;
}
......@@ -10,6 +10,9 @@ import lombok.Data;
public class TransactionDTO {
private Long debtorBBAN;
private Long creditorBBAN;
private BigDecimal amount;
}
......@@ -37,10 +37,11 @@ public class Account {
private BankProfile bankProfile;
/**
* Constructor for account.
* Generate a random balance for the account when an instance is created.
* Constructor for account. Generate a random balance for the account when an instance
* is created.
*/
public Account() {
this.balance = RandomValue.generateAccountBalance();
}
}
......@@ -15,8 +15,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Entity that represents a bank profile in the system.
* This profile consists of both an id and a social security number.
* Entity that represents a bank profile in the system. This profile consists of both an
* id and a social security number.
*/
@Data
@AllArgsConstructor
......@@ -37,4 +37,5 @@ public class BankProfile {
@JsonManagedReference
@JoinColumn(name = "bank_profile_id")
private List<Account> accounts;
}
package no.ntnu.idi.stud.savingsapp.bank.model;
public enum TransactionType {
NO_COFFEE,
NO_CAR,
SHORTER_SHOWER,
SPEND_LESS_ON_FOOD,
BUY_USED_CLOTHES,
LESS_SHOPPING,
DROP_SUBSCRIPTION,
SELL_SOMETHING,
BUY_USED,
EAT_PACKED_LUCH,
STOP_SHOPPING,
ZERO_SPENDING,
RENT_YOUR_STUFF,
MEATLESS_MONTH,
SCREEN_TIME_LIMIT,
UNPLUGGED_ENTERTAINMENT,
NO_COFFEE, NO_CAR, SHORTER_SHOWER, SPEND_LESS_ON_FOOD, BUY_USED_CLOTHES, LESS_SHOPPING, DROP_SUBSCRIPTION,
SELL_SOMETHING, BUY_USED, EAT_PACKED_LUCH, STOP_SHOPPING, ZERO_SPENDING, RENT_YOUR_STUFF, MEATLESS_MONTH,
SCREEN_TIME_LIMIT, UNPLUGGED_ENTERTAINMENT,
}
......@@ -5,14 +5,13 @@ import java.math.RoundingMode;
import java.util.Random;
/**
* Class for generating random values.
* This class is used in the bank application to generate random values for test data.
* Class for generating random values. This class is used in the bank application to
* generate random values for test data.
*/
public class RandomValue {
/**
* Generates a random {@link BigDecimal} number between 100 and 100_000.
*
* @return A random number.
*/
public static BigDecimal generateAccountBalance() {
......
......@@ -19,8 +19,8 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
/**
* Get all accounts that belong to a user with a specified id.
*
* @param bankProfileId The id of the bank profile that belongs to the desired accounts.
* @param bankProfileId The id of the bank profile that belongs to the desired
* accounts.
* @return A list of accounts.
*/
@Query("SELECT a FROM Account a WHERE a.bankProfile.id = :bankProfileId")
......@@ -28,7 +28,6 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
/**
* Get all accounts that belong to a user with a specified social security number.
*
* @param ssn The Social Security Number of the user.
* @return A list of accounts.
*/
......@@ -36,7 +35,6 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
/**
* Update the balance of an account.
*
* @param amount The new balance of the account.
* @param bban The Basic Bank Account Number, specifying which account is updated.
* @return The number of affected rows.
......@@ -48,9 +46,9 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
/**
* Get an account given the Basic Bank Account Number
*
* @param bban The Basic Bank Account Number belonging to the account.
* @return The account if it exists, if not: return empty.
*/
Optional<Account> findAccountByBban(Long bban);
}
......@@ -13,7 +13,6 @@ public interface BankProfileRepository extends JpaRepository<BankProfile, Long>
/**
* Get the bank profile associated with a Social Security Number.
*
* @param ssn The Social Security Number of the user.
* @return The user if it exists, if not: returns empty.
*/
......
......@@ -13,17 +13,16 @@ import org.springframework.stereotype.Service;
public interface AccountService {
/**
* Get a list of accounts of a bank profile by providing the associated id of the bank profile.
*
* Get a list of accounts of a bank profile by providing the associated id of the bank
* profile.
* @param id The id of the bank profile.
* @return A list of accounts.
*/
List<Account> getAccountsByBankProfileId(Long id);
/**
* Get a list of accounts of a bank profile by providing the associated Social Security Number
* of the bank profile.
*
* Get a list of accounts of a bank profile by providing the associated Social
* Security Number of the bank profile.
* @param ssn The Social Security Number of the bank profile.
* @return A list of accounts.
*/
......@@ -31,7 +30,6 @@ public interface AccountService {
/**
* Saves an account to the database.
*
* @param accountRequestDto The DTO containing the bank profile id.
* @return The saved account.
*/
......@@ -39,7 +37,6 @@ public interface AccountService {
/**
* Get an account given the Basic Bank Account Number
*
* @param bban The Basic Bank Account Number belonging to the account.
* @return The account if it exists, if not: return empty.
*/
......
......@@ -12,9 +12,9 @@ public interface BankProfileService {
/**
* Create a new bank profile.
*
* @param bankProfileDTO The DTO containing the user's Social Security Number.
* @return a {@link BankProfileResponseDTO} containing profile information.
*/
BankProfileResponseDTO saveBankProfile(BankProfileDTO bankProfileDTO);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment