git add .

This commit is contained in:
罗祥
2019-01-16 14:24:37 +08:00
parent 7c3e42909c
commit c19c349fd5
19 changed files with 206 additions and 38 deletions

View File

@ -9,6 +9,8 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
/**
* @author : heibaiying
@ -20,16 +22,18 @@ public class ProductService implements IProductService, ApplicationListener<WebS
private static List<Product> productList = new ArrayList<>();
public Product queryProductById(int id) {
for (Product product : productList) {
if (product.getId() == id) {
return product;
}
}
return null;
return productList.stream().filter(p->p.getId()==id).collect(Collectors.toList()).get(0);
}
public List<Product> queryAllProducts() {
// 用于测试 hystrix 超时熔断
try {
int i = new Random().nextInt(2500);
Thread.sleep(i);
} catch (InterruptedException e) {
e.printStackTrace();
}
return productList;
}

View File

@ -9,3 +9,4 @@ eureka:
client:
serviceUrl:
defaultZone: http://localhost:8010/eureka/