-
Notifications
You must be signed in to change notification settings - Fork 10
Salvatore's Exercise - Complete #7
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
Open
Gladiatrix4
wants to merge
1
commit into
ih-java-08-25:main
Choose a base branch
from
Gladiatrix4:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/com/ironhack/exercisechecksolutions/ExerciseCheckSolutionsApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.ironhack.exercisechecksolutions; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @SpringBootApplication | ||
| public class ExerciseCheckSolutionsApplication { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(ExerciseCheckSolutionsApplication.class, args); | ||
| } | ||
|
|
||
| } |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/ironhack/exercisechecksolutions/controller/TransactionController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package com.ironhack.exercisechecksolutions.controller; | ||
|
|
||
| import com.ironhack.exercisechecksolutions.enums.Attribute; | ||
| import com.ironhack.exercisechecksolutions.enums.Currency; | ||
| import com.ironhack.exercisechecksolutions.model.Transaction; | ||
| import com.ironhack.exercisechecksolutions.service.TransactionService; | ||
| import jakarta.websocket.server.PathParam; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/transactions") | ||
| public class TransactionController { | ||
|
|
||
| private final TransactionService transactionService; | ||
|
|
||
| public TransactionController(TransactionService transactionService){ | ||
| this.transactionService = transactionService; | ||
| } | ||
|
|
||
| @PostMapping | ||
| public Transaction create(@RequestBody Transaction transaction){ | ||
| return transactionService.create(transaction); | ||
| } | ||
|
|
||
| @GetMapping("/all") | ||
| public List<Transaction> getAllTransactions(){ | ||
| return transactionService.getAllTransactions(); | ||
| } | ||
|
|
||
| @PutMapping("/{id}") | ||
| public Transaction update(@PathVariable UUID id,@RequestBody Transaction transaction){ | ||
| return transactionService.updateTransaction(id, transaction); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public void deleteTransaction(@PathVariable UUID id) { | ||
| transactionService.deleteTransaction(id); | ||
| } | ||
|
|
||
|
|
||
| @GetMapping("/attribute/{attribute}") | ||
| public List<Transaction> getTransactionsByAttribute(@PathVariable Attribute attribute){ | ||
| return transactionService.findByAttribute(attribute); | ||
| } | ||
|
|
||
| @GetMapping("/currency/{currency}") | ||
| public List<Transaction> getTransactionsByCurrency(@PathVariable Currency currency){ | ||
| return transactionService.findByCurrency(currency); | ||
| } | ||
|
|
||
| @GetMapping("/accountHolder/{accountHolder}") | ||
| public List<Transaction> getTransactionsByAccountHolder(@PathVariable String accountHolder){ | ||
| return transactionService.findByAccountHolderName(accountHolder); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
93 changes: 93 additions & 0 deletions
93
src/main/java/com/ironhack/exercisechecksolutions/demo/DataLoader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package com.ironhack.exercisechecksolutions.demo; | ||
|
|
||
| import com.ironhack.exercisechecksolutions.enums.AccountType; | ||
| import com.ironhack.exercisechecksolutions.enums.Attribute; | ||
| import com.ironhack.exercisechecksolutions.enums.Currency; | ||
| import com.ironhack.exercisechecksolutions.enums.TransactionType; | ||
| import com.ironhack.exercisechecksolutions.model.Transaction; | ||
| import com.ironhack.exercisechecksolutions.service.TransactionService; | ||
| import org.springframework.boot.CommandLineRunner; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Component | ||
| public class DataLoader implements CommandLineRunner { | ||
|
|
||
| private final TransactionService transactionService; | ||
|
|
||
| public DataLoader(TransactionService transactionService) { | ||
| this.transactionService = transactionService; | ||
| } | ||
|
|
||
| @Override | ||
| public void run(String... args) throws Exception { | ||
| System.out.println("Loading initial data..."); | ||
| if (!transactionService.getAllTransactions().isEmpty()) { | ||
| System.out.println("Data already loaded, skipping..."); | ||
| return; | ||
| } | ||
|
|
||
| var transaction1 = new Transaction("Petros Kostenidis", | ||
| "PK_JPM_BANK_3", | ||
| AccountType.CHECKING_ACCOUNT, | ||
| "US00 0010 4657 6548 9990", | ||
| LocalTime.of(15,50,15), | ||
| LocalDate.of(2025,9,14), | ||
| LocalDate.of(2025,9,14), | ||
| TransactionType.DEBIT, | ||
| Currency.USD, | ||
| "CAFETERIALO MARKO RODA 6767_G4DPFDM5TG", | ||
| BigDecimal.valueOf(17.23), | ||
| Attribute.Expense, | ||
| "Recreation", | ||
| "Coffee", | ||
| "Fredo Espresso,Medium Sugar"); | ||
| transactionService.create(transaction1); | ||
| System.out.println("Data loaded!"); | ||
|
|
||
| var transaction2 = new Transaction("Petros Kostenidis", | ||
| "PK_JPM_BANK_2", | ||
| AccountType.CHECKING_ACCOUNT, | ||
| "US200 0010 4657 6548 9990", | ||
| LocalTime.of(19,50,15), | ||
| LocalDate.of(2025,9,4), | ||
| LocalDate.of(2025,9,5), | ||
| TransactionType.DEBIT, | ||
| Currency.USD, | ||
| "ELECTROPLANET Laptop 965DC85D", | ||
| BigDecimal.valueOf(800.20), | ||
| Attribute.Expense, | ||
| "Electronic Device", | ||
| "Laptop", | ||
| "Lenovo 656hx"); | ||
| transactionService.create(transaction1); | ||
| System.out.println("Data loaded!"); | ||
|
|
||
| var transaction3 = new Transaction("Petros Kostenidis", | ||
| "PK_JPM_BANK_3", | ||
| AccountType.CHECKING_ACCOUNT, | ||
| "US00 0010 4657 6548 9990", | ||
| LocalTime.of(17,50,02), | ||
| LocalDate.of(2025,9,02), | ||
| LocalDate.of(2025,9,02), | ||
| TransactionType.DEBIT, | ||
| Currency.USD, | ||
| "FURNITURAKIA 858585 ASDL", | ||
| BigDecimal.valueOf(17.23), | ||
| Attribute.Expense, | ||
| "Household", | ||
| "Furniture", | ||
| "Sofa"); | ||
|
|
||
| transactionService.create(transaction1); | ||
| transactionService.create(transaction2); | ||
| transactionService.create(transaction3); | ||
| System.out.println("Data loaded!"); | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/ironhack/exercisechecksolutions/enums/AccountType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.ironhack.exercisechecksolutions.enums; | ||
|
|
||
| public enum AccountType { | ||
| CHECKING_ACCOUNT, | ||
| DEPOSIT_ACCOUNT, | ||
| SAVINGS_ACCOUNT, | ||
| EMERGENCY_FUND_ACCOUNT, | ||
| CREDIT_CARD_ACCOUNT, | ||
| INVESTMENT_ACCOUNT, | ||
| CRYPTO_ACCOUNT | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/ironhack/exercisechecksolutions/enums/Attribute.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.ironhack.exercisechecksolutions.enums; | ||
|
|
||
| public enum Attribute { | ||
| Income, | ||
| Expense, | ||
| Zero_Value_Transaction | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/ironhack/exercisechecksolutions/enums/Currency.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.ironhack.exercisechecksolutions.enums; | ||
|
|
||
| public enum Currency { | ||
| USD, | ||
| EUR, | ||
| GBP, | ||
| CHF, | ||
| CNY, | ||
| JPY, | ||
| AUD, | ||
| CAD, | ||
| HKD, | ||
| NZD, | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/ironhack/exercisechecksolutions/enums/TransactionType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.ironhack.exercisechecksolutions.enums; | ||
|
|
||
| public enum TransactionType { | ||
| DEBIT, | ||
| CREDIT, | ||
| TRANSFER, | ||
| CASH_DEPOSIT, | ||
| WITHDRAWAL, | ||
| INTEREST, | ||
| CHARGES, | ||
| TAXES | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
no need to use /all, should be just transactions