account module refactoring
This commit is contained in:
@@ -1 +0,0 @@
|
||||
description('account-adapter')
|
||||
@@ -1 +0,0 @@
|
||||
description('account api module')
|
||||
@@ -1 +0,0 @@
|
||||
description('api model for account domain')
|
||||
@@ -1 +0,0 @@
|
||||
description 'domain implementation of banck account'
|
||||
@@ -1 +0,0 @@
|
||||
description('account implementation of infrastructure layer')
|
||||
9
bank-account/account/account-adapters/build.gradle
Normal file
9
bank-account/account/account-adapters/build.gradle
Normal file
@@ -0,0 +1,9 @@
|
||||
description('account-adapter')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account:account-api')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
}
|
||||
8
bank-account/account/account-api/build.gradle
Normal file
8
bank-account/account/account-api/build.gradle
Normal file
@@ -0,0 +1,8 @@
|
||||
description('account api module')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
}
|
||||
6
bank-account/account/account-domain-api/build.gradle
Normal file
6
bank-account/account/account-domain-api/build.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
description('api model for account domain')
|
||||
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import com.mz.reactor.ddd.common.api.view.DomainView;
|
||||
import org.immutables.value.Value;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Value.Immutable
|
||||
@@ -2,7 +2,6 @@ package com.mz.reactor.ddd.reactorddd.account.domain.command;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.event.ImmutableMoneyWithdrawn;
|
||||
import org.immutables.value.Value;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.immutables.value.Value;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Value.Immutable
|
||||
@JsonSerialize(as = ImmutableWithdrawTransferMoney.class)
|
||||
@JsonDeserialize(as = ImmutableWithdrawTransferMoney.class)
|
||||
@@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.immutables.value.Value;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Value.Immutable
|
||||
@JsonSerialize(as = ImmutableTransferMoneyDeposited.class)
|
||||
@JsonDeserialize(as = ImmutableTransferMoneyDeposited.class)
|
||||
@@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.WithdrawTransferMoney;
|
||||
import org.immutables.value.Value;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Value.Immutable
|
||||
@JsonSerialize(as = ImmutableTransferMoneyWithdrawn.class)
|
||||
@JsonDeserialize(as = ImmutableTransferMoneyWithdrawn.class)
|
||||
6
bank-account/account/account-domain/build.gradle
Normal file
6
bank-account/account/account-domain/build.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
description 'domain implementation of banck account'
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class AccountEventHandlerTest {
|
||||
|
||||
7
bank-account/account/account-http-api/build.gradle
Normal file
7
bank-account/account/account-http-api/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
implementation project(':bank-account:account:account-api')
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mz.reactor.ddd.common.components.http.HttpHandler;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.model.*;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.AccountApplicationService;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.AccountQuery;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.AccountState;
|
||||
import com.mz.reactor.ddd.reactorddd.account.http.model.*;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -18,13 +21,21 @@ import static org.springframework.web.reactive.function.server.RequestPredicates
|
||||
@Component
|
||||
public class AccountHandler implements HttpHandler {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
private final AccountApplicationService service;
|
||||
|
||||
private final AccountQuery accountQuery;
|
||||
|
||||
private final Scheduler scheduler;
|
||||
|
||||
public AccountHandler(AccountApplicationService service, AccountQuery accountQuery, @Qualifier("JsonDesScheduler") Scheduler scheduler) {
|
||||
public AccountHandler(
|
||||
AccountApplicationService service,
|
||||
AccountQuery accountQuery,
|
||||
@Qualifier("JsonDesScheduler") Scheduler scheduler,
|
||||
ObjectMapper mapper
|
||||
) {
|
||||
this.mapper = mapper;
|
||||
this.service = service;
|
||||
this.accountQuery = accountQuery;
|
||||
this.scheduler = scheduler;
|
||||
@@ -78,4 +89,9 @@ public class AccountHandler implements HttpHandler {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMapper mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.api.model;
|
||||
package com.mz.reactor.ddd.reactorddd.account.http.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
13
bank-account/account/account-impl/build.gradle
Normal file
13
bank-account/account/account-impl/build.gradle
Normal file
@@ -0,0 +1,13 @@
|
||||
description('account implementation of infrastructure layer')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':common-persistence')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
api project(':bank-account:account:account-api')
|
||||
api project(':bank-account:account:account-domain')
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package com.mz.reactor.ddd.reactorddd.account.impl;
|
||||
|
||||
import com.mz.reactor.ddd.common.api.event.DomainEvent;
|
||||
import com.mz.reactor.ddd.common.components.bus.ApplicationMessageBus;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.AccountApplicationService;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.AccountAggregate;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.AccountState;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.*;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.event.*;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.AccountCommand;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.CreateAccount;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.DepositMoney;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.WithdrawMoney;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.event.AccountCreated;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.event.MoneyDeposited;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.event.MoneyWithdrawn;
|
||||
import com.mz.reactor.ddd.reactorddd.persistance.aggregate.AggregateFacade;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.domain.event.TransactionCreated;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.domain.event.TransactionFailed;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class AccountApplicationServiceImpl implements AccountApplicationService {
|
||||
|
||||
@@ -1 +1,22 @@
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
description = 'back account application'
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
implementation project(':common-api')
|
||||
implementation project(':common-components')
|
||||
implementation project(':common-persistence')
|
||||
implementation project(':bank-account:account:account-impl')
|
||||
implementation project(':bank-account:account:account-api')
|
||||
implementation project(':bank-account:account:account-http-api')
|
||||
implementation project(':bank-account:account:account-domain')
|
||||
implementation project(':bank-account:account:account-adapters')
|
||||
implementation project(':bank-account:transaction-impl')
|
||||
implementation project(':bank-account:transaction-api')
|
||||
implementation project(':bank-account:transaction-domain')
|
||||
implementation project(':bank-account:transaction-adapters')
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
}
|
||||
@@ -2,14 +2,16 @@ package com.mz.reactor.ddd.reactorddd.application;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import reactor.blockhound.BlockHound;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class BankAccountApp {
|
||||
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
static {
|
||||
BlockHound.install();
|
||||
// BlockHound.install();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -17,4 +19,9 @@ public class BankAccountApp {
|
||||
SpringApplication.run(BankAccountApp.class, args);
|
||||
}
|
||||
|
||||
// @PostConstruct
|
||||
// public void setUp() {
|
||||
// objectMapper.registerModule(new JavaTimeModule());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.mz.reactor.ddd.reactorddd.application;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.mz.reactor.ddd.common.components.http.HttpHandlerFunctions;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.AccountHandler;
|
||||
import com.mz.reactor.ddd.reactorddd.account.http.AccountHandler;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.api.TransactionHandler;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
@@ -42,4 +46,12 @@ public class BankAccountAppConfiguration {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
ObjectMapper objectMapper = builder.build();
|
||||
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
spring:
|
||||
jackson:
|
||||
serialization:
|
||||
write-dates-as-timestamps: false
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mz.reactor.ddd.reactorddd.application;
|
||||
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.model.CreateAccountRequest;
|
||||
import com.mz.reactor.ddd.reactorddd.account.api.model.CreateAccountResponse;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.AccountState;
|
||||
import com.mz.reactor.ddd.reactorddd.account.domain.command.CreateAccount;
|
||||
import com.mz.reactor.ddd.reactorddd.account.http.model.CreateAccountRequest;
|
||||
import com.mz.reactor.ddd.reactorddd.account.http.model.CreateAccountResponse;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.api.model.CreateTransactionRequest;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.api.model.CreateTransactionResponse;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.domain.TransactionState;
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
description('transactions-adapters')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:transaction-api')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
}
|
||||
|
||||
@@ -1 +1,8 @@
|
||||
description('transaction-api module')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mz.reactor.ddd.reactorddd.transaction.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mz.reactor.ddd.common.components.http.HttpHandler;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.api.model.CreateTransactionRequest;
|
||||
import com.mz.reactor.ddd.reactorddd.transaction.api.model.CreateTransactionResponse;
|
||||
@@ -23,9 +24,12 @@ public class TransactionHandler implements HttpHandler {
|
||||
|
||||
private final TransactionQuery query;
|
||||
|
||||
public TransactionHandler(TransactionApplicationService transactionApplicationService, TransactionQuery query) {
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public TransactionHandler(TransactionApplicationService transactionApplicationService, TransactionQuery query, ObjectMapper mapper) {
|
||||
this.service = Objects.requireNonNull(transactionApplicationService);
|
||||
this.query = Objects.requireNonNull(query);
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> getAll(ServerRequest request) {
|
||||
@@ -58,4 +62,9 @@ public class TransactionHandler implements HttpHandler {
|
||||
.nest(path("/transactions"), () -> route)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMapper mapper() {
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
description('domain api modele for transaction domain')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
description 'bank transation domain'
|
||||
description 'bank transation domain'
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
}
|
||||
@@ -1 +1,12 @@
|
||||
description('transaction-impl module')
|
||||
description('transaction-impl module')
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':common-persistence')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account:account-domain-api')
|
||||
api project(':bank-account:transaction-api')
|
||||
api project(':bank-account:transaction-domain')
|
||||
}
|
||||
170
build.gradle
170
build.gradle
@@ -53,10 +53,16 @@ subprojects {
|
||||
dependencies {
|
||||
implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
|
||||
implementation 'io.projectreactor.tools:blockhound:1.0.0.RC1'
|
||||
annotationProcessor 'org.immutables:value:2.7.5'
|
||||
annotationProcessor "org.immutables:value:$immutablesVersion"
|
||||
implementation "org.immutables:value:$immutablesVersion"
|
||||
implementation "com.fasterxml.jackson.core:jackson-core"
|
||||
implementation "com.fasterxml.jackson.core:jackson-databind"
|
||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
|
||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
|
||||
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine'
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
|
||||
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.14.0'
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
|
||||
}
|
||||
|
||||
test {
|
||||
@@ -65,163 +71,3 @@ subprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project(':common-api') {
|
||||
dependencies {
|
||||
api project(':shared-dependencies')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:bank-account-application') {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
implementation project(':common-api')
|
||||
implementation project(':common-components')
|
||||
implementation project(':common-persistence')
|
||||
implementation project(':bank-account:account-impl')
|
||||
implementation project(':bank-account:account-api')
|
||||
implementation project(':bank-account:account-domain')
|
||||
implementation project(':bank-account:account-adapters')
|
||||
implementation project(':bank-account:transaction-impl')
|
||||
implementation project(':bank-account:transaction-api')
|
||||
implementation project(':bank-account:transaction-domain')
|
||||
implementation project(':bank-account:transaction-adapters')
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:account-domain') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:account-domain-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:account-domain-api') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:account-api') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:account-domain-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:transaction-api') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:account-impl') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':common-persistence')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account-domain-api')
|
||||
api project(':bank-account:account-api')
|
||||
api project(':bank-account:account-domain')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
project(':bank-account:transaction-adapters') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:transaction-api')
|
||||
api project(':bank-account:account-domain-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:transaction-impl') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':common-components')
|
||||
api project(':common-persistence')
|
||||
api project(':shared-spring-dependencies')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account-domain-api')
|
||||
api project(':bank-account:transaction-api')
|
||||
api project(':bank-account:transaction-domain')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:transaction-domain') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:account-adapters') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':bank-account:transaction-domain-api')
|
||||
api project(':bank-account:account-api')
|
||||
api project(':bank-account:account-domain-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
}
|
||||
}
|
||||
|
||||
project(':bank-account:transaction-domain-api') {
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
}
|
||||
}
|
||||
|
||||
project(':shared-dependencies') {
|
||||
dependencies {
|
||||
api "org.immutables:value:$immutablesVersion"
|
||||
api "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
|
||||
api "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
|
||||
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
|
||||
}
|
||||
}
|
||||
|
||||
project(':shared-spring-dependencies') {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
dependencies {
|
||||
api group: 'io.projectreactor', name: 'reactor-core'
|
||||
api 'org.springframework:spring-context'
|
||||
api 'org.springframework:spring-webflux'
|
||||
api 'org.springframework:spring-core'
|
||||
}
|
||||
}
|
||||
|
||||
project(':common-persistence') {
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
// implementation group: 'io.projectreactor', name: 'reactor-core'
|
||||
api project(':shared-spring-dependencies')
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
project(':common-components') {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
description = 'common API'
|
||||
|
||||
dependencies {
|
||||
api project(':shared-dependencies')
|
||||
}
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
description('common compents such as message-buss component ...')
|
||||
|
||||
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
api project(':shared-spring-dependencies')
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
implementation "org.immutables:value:$immutablesVersion"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mz.reactor.ddd.common.components.http;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
@@ -13,14 +14,16 @@ public interface HttpHandler {
|
||||
|
||||
RouterFunction<ServerResponse> route();
|
||||
|
||||
ObjectMapper mapper();
|
||||
|
||||
default <T> Mono<T> bodyToMono(ServerRequest request, Class<T> clazz, Scheduler scheduler) {
|
||||
return request.bodyToMono(String.class)
|
||||
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz, scheduler));
|
||||
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz, scheduler, mapper()));
|
||||
}
|
||||
|
||||
default <T> Mono<T> bodyToMono(ServerRequest request, Class<T> clazz) {
|
||||
return request.bodyToMono(String.class)
|
||||
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz));
|
||||
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz, mapper()));
|
||||
}
|
||||
|
||||
default <T> Mono<ServerResponse> mapToResponse(T result) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mz.reactor.ddd.common.components.http;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
@@ -19,20 +18,24 @@ import static org.springframework.web.reactive.function.BodyInserters.fromObject
|
||||
public enum HttpHandlerFunctions {
|
||||
FN;
|
||||
|
||||
public <T> Function<String, Mono<T>> deserializeJsonString(@Nonnull Class<T> clazz, @Nonnull Scheduler scheduler) {
|
||||
return value -> Mono.fromCallable(() -> {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new Jdk8Module());
|
||||
return mapper.readValue(value, clazz);
|
||||
}).subscribeOn(scheduler);
|
||||
// private final ObjectMapper mapper;
|
||||
//
|
||||
// HttpHandlerFunctions() {
|
||||
// mapper = new ObjectMapper();
|
||||
// mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
// mapper.registerModule(new Jdk8Module());
|
||||
// }
|
||||
|
||||
public <T> Function<String, Mono<T>> deserializeJsonString(
|
||||
@Nonnull Class<T> clazz,
|
||||
@Nonnull Scheduler scheduler,
|
||||
@Nonnull ObjectMapper mapper
|
||||
) {
|
||||
return value -> Mono.fromCallable(() -> mapper.readValue(value, clazz)).subscribeOn(scheduler);
|
||||
}
|
||||
|
||||
public <T> Function<String, Mono<T>> deserializeJsonString(@Nonnull Class<T> clazz) {
|
||||
return value -> Mono.fromCallable(() -> {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new Jdk8Module());
|
||||
return mapper.readValue(value, clazz);
|
||||
}).subscribeOn(Schedulers.elastic());
|
||||
public <T> Function<String, Mono<T>> deserializeJsonString(@Nonnull Class<T> clazz, @Nonnull ObjectMapper mapper) {
|
||||
return value -> Mono.fromCallable(() -> mapper.readValue(value, clazz)).subscribeOn(Schedulers.elastic());
|
||||
}
|
||||
|
||||
public <E extends Throwable> Mono<ServerResponse> onError(E e, ServerRequest req, Consumer<E> logger) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
dependencies {
|
||||
api project(':common-api')
|
||||
// implementation group: 'io.projectreactor', name: 'reactor-core'
|
||||
api project(':shared-spring-dependencies')
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mz.reactor.ddd.reactorddd.persistance.aggregate.impl;
|
||||
|
||||
public class Person {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String surname;
|
||||
|
||||
private Person(Builder builder) {
|
||||
name = builder.name;
|
||||
surname = builder.surname;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static Builder newBuilder(Person copy) {
|
||||
Builder builder = new Builder();
|
||||
builder.name = copy.getName();
|
||||
builder.surname = copy.getSurname();
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private String name;
|
||||
private String surname;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder withName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withSurname(String surname) {
|
||||
this.surname = surname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Person build() {
|
||||
return new Person(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mz.reactor.ddd.reactorddd.persistance.aggregate.impl;
|
||||
|
||||
public class TestData {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String signature;
|
||||
|
||||
private final String numbers;
|
||||
|
||||
private TestData(Builder builder) {
|
||||
name = builder.name;
|
||||
signature = builder.signature;
|
||||
numbers = builder.numbers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String getNumbers() {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static Builder newBuilder(TestData copy) {
|
||||
Builder builder = new Builder();
|
||||
builder.name = copy.getName();
|
||||
builder.signature = copy.getSignature();
|
||||
builder.numbers = copy.getNumbers();
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private String name;
|
||||
private String signature;
|
||||
private String numbers;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder withName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withSignature(String signature) {
|
||||
this.signature = signature;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withNumbers(String numbers) {
|
||||
this.numbers = numbers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TestData build() {
|
||||
return new TestData(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,27 @@
|
||||
//pluginManagement {
|
||||
// id 'io.spring.dependency-management' version "$springDependencyMavagementVersion"
|
||||
// id 'java'
|
||||
// id 'java-library'
|
||||
//}
|
||||
|
||||
|
||||
rootProject.name = 'reactor-ddd'
|
||||
include 'common-api'
|
||||
include 'bank-account:bank-account-application'
|
||||
include 'bank-account:account-domain'
|
||||
include 'bank-account:transaction-domain'
|
||||
include 'shared-dependencies'
|
||||
include 'shared-spring-dependencies'
|
||||
include 'common-persistence'
|
||||
include 'common-components'
|
||||
include 'bank-account:account-domain-api'
|
||||
include 'bank-account:bank-account-application'
|
||||
include 'bank-account:account:account-domain'
|
||||
include 'bank-account:account:account-domain-api'
|
||||
include 'bank-account:account:account-api'
|
||||
include 'bank-account:account:account-impl'
|
||||
include 'bank-account:account:account-adapters'
|
||||
include 'bank-account:transaction-domain'
|
||||
include 'bank-account:transaction-domain-api'
|
||||
include 'bank-account:account-api'
|
||||
include 'bank-account:account-impl'
|
||||
include 'bank-account:transaction-impl'
|
||||
include 'bank-account:transaction-api'
|
||||
include 'bank-account:account-adapters'
|
||||
include 'bank-account:transaction-adapters'
|
||||
include 'bank-account:account:account-http-api'
|
||||
findProject(':bank-account:account:account-http-api')?.name = 'account-http-api'
|
||||
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
description 'shared dependencies'
|
||||
|
||||
|
||||
dependencies {
|
||||
api group: 'io.projectreactor', name: 'reactor-core'
|
||||
api 'org.springframework:spring-context'
|
||||
api 'org.springframework:spring-webflux'
|
||||
api 'org.springframework:spring-core'
|
||||
}
|
||||
Reference in New Issue
Block a user