Created
November 16, 2020 10:49
-
-
Save dev-aritra/7c70bba0dbb5a5310ac2169a34aed8e3 to your computer and use it in GitHub Desktop.
This file contains 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
@Service | |
public class StoreService implements StoreManagementUseCase { | |
private final StorePort storePort; | |
private final UpdateStoreCountInZipCodePort updateStoreCountInZipCodePort; | |
@Autowired | |
public StoreService(StorePort storePort, UpdateStoreCountInZipCodePort updateStoreCountInZipCodePort) { | |
this.storePort = storePort; | |
this.updateStoreCountInZipCodePort = updateStoreCountInZipCodePort; | |
} | |
@Override | |
@Transactional | |
public Mono<Store> addStore(Store store) { | |
if (store.isValid()) { | |
final Mono<Store> result = storePort.addStore(store); | |
updateStoreCountInZipCodePort.incrementStoreCount(store.getLocation().getZipCode()); | |
return result; | |
} | |
return Mono.error(InvalidAttributesException::new); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment