Created
March 19, 2021 03:56
-
-
Save srdelarosa/bb700b619c30a9968bb492ab5438fbce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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