Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Online Banking Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Filip Kollár
Online Banking Service
Commits
31811b20
There was an error fetching the commit references. Please try again later.
Commit
31811b20
authored
10 months ago
by
Pavel Tetauer
Committed by
Filip Fabry
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Added seeding data
parent
26bd14f8
No related branches found
No related tags found
1 merge request
!40
added sequence generation of account numbers
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
transaction-service/src/main/java/cz/muni/fi/obs/data/TransactionServiceDataSeeder.java
+58
-9
58 additions, 9 deletions
...ava/cz/muni/fi/obs/data/TransactionServiceDataSeeder.java
with
58 additions
and
9 deletions
transaction-service/src/main/java/cz/muni/fi/obs/data/TransactionServiceDataSeeder.java
+
58
−
9
View file @
31811b20
package
cz.muni.fi.obs.data
;
import
cz.muni.fi.obs.api.ScheduledPaymentCreateDto
;
import
cz.muni.fi.obs.api.TransactionCreateDto
;
import
cz.muni.fi.obs.data.dbo.AccountDbo
;
import
cz.muni.fi.obs.data.dbo.PaymentFrequency
;
import
cz.muni.fi.obs.data.repository.AccountRepository
;
import
cz.muni.fi.obs.data.repository.ScheduledPaymentRepository
;
import
cz.muni.fi.obs.data.repository.TransactionRepository
;
import
cz.muni.fi.obs.facade.TransactionManagementFacade
;
import
cz.muni.fi.obs.service.TransactionService
;
import
cz.muni.fi.obs.
util.JsonConvertor
;
import
cz.muni.fi.obs.
service.payment.ScheduledPaymentService
;
import
cz.muni.fi.obs.util.Resources
;
import
jakarta.annotation.PostConstruct
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flywaydb.core.internal.util.JsonUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.util.List
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
...
@@ -25,19 +29,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
@Slf4j
public
class
TransactionServiceDataSeeder
{
private
final
ScheduledPaymentRepository
scheduledPaymentRepository
;
private
final
TransactionRepository
transactionRepository
;
private
final
AccountRepository
accountRepository
;
private
final
TransactionService
transactionService
;
private
final
ScheduledPaymentService
scheduledPaymentService
;
private
final
TransactionManagementFacade
transactionManagementFacade
;
@Autowired
public
TransactionServiceDataSeeder
(
AccountRepository
accountRepository
,
TransactionRepository
transactionRepository
,
ScheduledPaymentRepository
scheduledPaymentRepository
,
TransactionService
transactionService
)
{
ScheduledPaymentRepository
scheduledPaymentRepository
,
TransactionService
transactionService
,
ScheduledPaymentService
scheduledPaymentService
,
TransactionManagementFacade
transactionManagementFacade
)
{
this
.
accountRepository
=
accountRepository
;
this
.
transactionRepository
=
transactionRepository
;
this
.
scheduledPaymentRepository
=
scheduledPaymentRepository
;
this
.
transactionService
=
transactionService
;
this
.
scheduledPaymentService
=
scheduledPaymentService
;
this
.
transactionManagementFacade
=
transactionManagementFacade
;
}
@PostConstruct
...
...
@@ -45,11 +50,34 @@ public class TransactionServiceDataSeeder {
log
.
info
(
"Initializing transaction service data..."
);
List
<
AccountDbo
>
accounts
=
createAccounts
();
createTransactions
(
accounts
);
createScheduledPayments
(
accounts
);
log
.
info
(
"Initialized transaction service data..."
);
}
private
void
createTransactions
(
List
<
AccountDbo
>
accounts
)
{
transactionManagementFacade
.
createTransaction
(
new
TransactionCreateDto
(
accounts
.
get
(
0
).
getId
(),
accounts
.
getLast
().
getId
(),
new
BigDecimal
(
10000
),
"Test transaction 1"
,
"123456"
));
transactionManagementFacade
.
createTransaction
(
new
TransactionCreateDto
(
accounts
.
get
(
2
).
getId
(),
accounts
.
get
(
3
).
getId
(),
new
BigDecimal
(
20000
),
"Test transaction 2"
,
"654321"
));
transactionManagementFacade
.
createTransaction
(
new
TransactionCreateDto
(
accounts
.
get
(
3
).
getId
(),
accounts
.
get
(
4
).
getId
(),
new
BigDecimal
(
30000
),
"Test transaction 3"
,
"987654"
));
}
private
List
<
AccountDbo
>
createAccounts
()
{
...
...
@@ -62,5 +90,26 @@ public class TransactionServiceDataSeeder {
}
private
void
createScheduledPayments
(
List
<
AccountDbo
>
accounts
)
{
scheduledPaymentService
.
createPayment
(
new
ScheduledPaymentCreateDto
(
LocalDate
.
of
(
2024
,
6
,
6
),
null
,
PaymentFrequency
.
YEARLY
,
accounts
.
getFirst
().
getId
(),
accounts
.
getLast
().
getId
()
));
scheduledPaymentService
.
createPayment
(
new
ScheduledPaymentCreateDto
(
LocalDate
.
of
(
2024
,
7
,
7
),
null
,
PaymentFrequency
.
MONTHLY
,
accounts
.
get
(
1
).
getId
(),
accounts
.
get
(
2
).
getId
()
));
scheduledPaymentService
.
createPayment
(
new
ScheduledPaymentCreateDto
(
LocalDate
.
of
(
2024
,
8
,
8
),
null
,
PaymentFrequency
.
WEEKLY
,
accounts
.
get
(
3
).
getId
(),
accounts
.
get
(
4
).
getId
()
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment