Skip to content

Commit 6079724

Browse files
committed
feat: aggiunto materiale per esercizio 7
1 parent c3989b8 commit 6079724

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

07_bank/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<groupId>org.springframework.boot</groupId>
2222
<artifactId>spring-boot-starter-validation</artifactId>
2323
</dependency>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter-data-mongodb</artifactId>
27+
</dependency>
2428

2529
<dependency>
2630
<groupId>org.springframework.boot</groupId>
@@ -32,6 +36,12 @@
3236
<artifactId>archunit-junit5</artifactId>
3337
<scope>test</scope>
3438
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.data</groupId>
41+
<artifactId>spring-data-commons</artifactId>
42+
<version>3.3.2</version>
43+
<scope>compile</scope>
44+
</dependency>
3545
</dependencies>
3646

3747
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.doubleloop.bank.adapter;
2+
3+
import java.time.LocalDate;
4+
5+
public class HttpNationalIdentityProvider {
6+
7+
// NOTE: First of all define the Domain's Port (method name, parameters and return value)
8+
// and then implement it with this Adapter.
9+
10+
private GetInfoResponse getInfo(String cf) {
11+
// NOTE: This is a fake implementation, it should be replaced with a real one
12+
return new GetInfoResponse(
13+
"foo",
14+
"bar",
15+
LocalDate.of(1982, 11, 8)
16+
);
17+
}
18+
19+
private static class GetInfoResponse {
20+
public final String firstName;
21+
public final String lastName;
22+
public final LocalDate dateOfBirth;
23+
24+
private GetInfoResponse(String firstName, String lastName, LocalDate dateOfBirth) {
25+
this.firstName = firstName;
26+
this.lastName = lastName;
27+
this.dateOfBirth = dateOfBirth;
28+
}
29+
}
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.doubleloop.bank.adapter;
2+
3+
import io.doubleloop.bank.domain.Account;
4+
import org.springframework.data.mongodb.repository.MongoRepository;
5+
6+
public interface SpringMongoAccountRepository extends MongoRepository<Account, String> {
7+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package io.doubleloop.bank.domain;
2+
3+
import org.springframework.data.annotation.Id;
4+
5+
import java.time.LocalDate;
6+
7+
public class Account {
8+
@Id
9+
private String id;
10+
11+
private String firstName;
12+
private String lastName;
13+
private String CF;
14+
private LocalDate dateOfBirth;
15+
private Double balance;
16+
private LocalDate openingDate;
17+
18+
public Account() {
19+
}
20+
21+
public Account(String firstName, String lastName, String CF, LocalDate dateOfBirth, Double balance, LocalDate openingDate) {
22+
this.firstName = firstName;
23+
this.lastName = lastName;
24+
this.CF = CF;
25+
this.dateOfBirth = dateOfBirth;
26+
this.balance = balance;
27+
this.openingDate = openingDate;
28+
}
29+
30+
public String getId() {
31+
return id;
32+
}
33+
34+
public String getFirstName() {
35+
return firstName;
36+
}
37+
38+
public String getLastName() {
39+
return lastName;
40+
}
41+
42+
public String getCF() {
43+
return CF;
44+
}
45+
46+
public LocalDate getDateOfBirth() {
47+
return dateOfBirth;
48+
}
49+
50+
public Double getBalance() {
51+
return balance;
52+
}
53+
54+
public LocalDate getOpeningDate() {
55+
return openingDate;
56+
}
57+
58+
public void deposit(Double amount) {
59+
balance += amount;
60+
}
61+
62+
public void withdraw(Double amount) {
63+
balance -= amount;
64+
}
65+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.doubleloop.bank.domain;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
@Service
6+
public class AccountService {
7+
8+
public void open() {
9+
}
10+
11+
public void close() {
12+
}
13+
14+
public void deposit() {
15+
}
16+
17+
public void withdraw() {
18+
}
19+
20+
public void transfer() {
21+
}
22+
}

0 commit comments

Comments
 (0)