blob: 03a60f94ffd420634cc8333ff00e00a65fe2d006 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package com.example.spring.bank.dev;
import java.math.BigDecimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.example.spring.bank.account.Account;
import com.example.spring.bank.account.AccountManager;
import com.example.spring.bank.customer.Customer;
import com.example.spring.bank.customer.CustomerManager;
@Component
public class AppInit implements CommandLineRunner {
@Autowired
private AccountManager accountManager;
@Autowired
private CustomerManager customerManager;
@Value("${bankapp.init-testdata}")
private boolean initTestData;
@Override
public void run(String... args) throws Exception {
// Create test accounts.
if (initTestData) {
Account acc1 = accountManager.create(new Account(new BigDecimal("0.00")));
Account acc2 = accountManager.create(new Account(new BigDecimal("0.00")));
Customer c1 = customerManager.create(new Customer("Madushi"));
Customer c2 = customerManager.create(new Customer("Anuradha"));
Customer customerSamitha = customerManager.create(new Customer("Samitha"));
Account accountSamitha = accountManager.create(new Account(new BigDecimal("0.00")));
customerManager.addAccount(customerSamitha, accountSamitha);
}
}
}
|