Skip to content

Instantly share code, notes, and snippets.

@dev-aritra
Created November 16, 2020 10:49
Show Gist options
  • Save dev-aritra/7c70bba0dbb5a5310ac2169a34aed8e3 to your computer and use it in GitHub Desktop.
Save dev-aritra/7c70bba0dbb5a5310ac2169a34aed8e3 to your computer and use it in GitHub Desktop.
@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