Skip to content

Instantly share code, notes, and snippets.

@srdelarosa
Created March 19, 2021 03:56
Show Gist options
  • Save srdelarosa/bb700b619c30a9968bb492ab5438fbce to your computer and use it in GitHub Desktop.
Save srdelarosa/bb700b619c30a9968bb492ab5438fbce to your computer and use it in GitHub Desktop.
package com.newhorizons.takeitnow.item.domain.service;
import com.newhorizons.takeitnow.item.application.mainmodule.service.IItemService;
import com.newhorizons.takeitnow.item.domain.entity.Item;
import com.newhorizons.takeitnow.item.domain.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ItemService implements IItemService {
@Autowired
private RestTemplate restTemplateClient;
public List<Item> getAll() {
List<Product> products = Arrays.asList(restTemplateClient.getForObject("http://localhost:8001/takeitnow/api/products/getAll", Product[].class));
return products.stream().map(p -> new Item(p, 1L)).collect(Collectors.toList());
}
public Item getItem(long productId, long quantity) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment